Bonfire.API.MastoCompat.Mappers.Status (Bonfire v1.0.1-social-alpha.28)

View Source

Maps Bonfire Activity/Post objects to Mastodon Status format.

This module consolidates all status transformation logic that was previously scattered across multiple prepare_* functions. It handles:

  • Timeline statuses (from Activity objects)
  • Reblog/boost statuses (nested Post objects)
  • Notification statuses
  • Fallback statuses (when object data is incomplete)

Usage

# Timeline status
Mappers.Status.from_activity(activity, current_user: user)

# Reblog (nested in a boost)
Mappers.Status.from_post(post, is_reblog: true)

# Notification status
Mappers.Status.from_post(post, for_notification: true, current_user: user)

Summary

Functions

Transform a Bonfire Activity into a Mastodon Status.

Transform a Bonfire Post into a Mastodon Status.

Functions

from_activity(activity, opts)

Transform a Bonfire Activity into a Mastodon Status.

Options

  • :current_user - The current user (for interaction states)
  • :for_notification - Set true when building status for notification
  • :fallback - Set true when object data may be incomplete

Examples

iex> from_activity(activity, current_user: user)
%{"id" => "123", "content" => "Hello", ...}

from_post(post, opts \\ [])

Transform a Bonfire Post into a Mastodon Status.

Used for reblog scenarios where we have a Post object without the outer Activity.

Options

  • :is_reblog - Set true when this Post is being nested in a reblog field
  • :for_notification - Set true when building status for notification
  • :current_user - The current user (for interaction states)