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

View Source

Transforms Bonfire Circles to Mastodon List format.

In Bonfire, Circles are used to group users for access control and content organization. This module maps them to the Mastodon List API format.

Handles both:

  • Direct Ecto struct format (atom keys, nested :named mixin)
  • GraphQL response format (string keys, flat structure)

Summary

Functions

Converts a Bonfire Circle to a Mastodon List format.

Functions

from_circle(circle)

Converts a Bonfire Circle to a Mastodon List format.

Returns nil if the input is nil, invalid, or fails validation.

Supports both Ecto struct format and GraphQL response format:

Examples

# Ecto struct format
iex> from_circle(%{id: "123", named: %{name: "Friends"}})
%{"id" => "123", "title" => "Friends"}

# GraphQL response format
iex> from_circle(%{"id" => "123", "name" => "Friends"})
%{"id" => "123", "title" => "Friends"}

iex> from_circle(nil)
nil