Bonfire.API.MastoCompat.Mappers.Notification (Bonfire v1.0.1-social-alpha.28)
View SourceMaps Bonfire Activity objects to Mastodon Notification format.
Handles transformation of Bonfire activities into Mastodon-compatible notifications, including mapping verb IDs to notification types and conditionally including status objects.
Notification Types
Per Mastodon API spec:
follow- Someone followed youfollow_request- Someone requested to follow youmention- Someone mentioned you in their statusreblog- Someone boosted one of your statusesfavourite- Someone favourited one of your statusespoll- A poll you have voted in or created has endedstatus- Someone you enabled notifications for has postedupdate- A status you interacted with has been edited
Usage
Mappers.Notification.from_activity(activity, current_user: user)
Summary
Functions
Transform a Bonfire Activity into a Mastodon Notification.
Maps a Bonfire verb ID to a Mastodon notification type.
Determines if a notification type should include a status object.
Functions
Transform a Bonfire Activity into a Mastodon Notification.
Returns nil if the notification is invalid (missing required fields).
Options
:current_user- The current user viewing the notification:subjects_by_id- Map of subject IDs to preloaded user data:post_content_by_id- Map of object IDs to preloaded post content:mentions_by_object- Map of object IDs to preloaded mentions
Examples
iex> from_activity(activity)
%{"id" => "123", "type" => "follow", "account" => %{...}}
iex> from_activity(invalid_activity)
nil
Maps a Bonfire verb ID to a Mastodon notification type.
For :create and :reply activities, checks if the current user was mentioned
to distinguish between "mention" (user was @mentioned) and "status" (subscribed to author).
Options
:current_user- The current user viewing notifications:mentions- List of mention tags from the post
Determines if a notification type should include a status object.