Bonfire.API.MastoCompat.Schemas.Notification (Bonfire v1.0.1-social-alpha.28)

View Source

Mastodon Notification entity schema definition.

Based on the Mastodon API OpenAPI spec (mastodon-openapi.yaml line 2778+). This module provides a single source of truth for Notification field structure and defaults.

All fields match the current implementation in graphql_masto_adapter.ex

Summary

Functions

Returns the default values for all Notification fields.

Returns a new Notification map with default values. Can optionally merge custom values via the overrides parameter.

List of required fields per the Mastodon OpenAPI specification.

List of valid notification types per the Mastodon API spec.

Validates that all required fields are present and non-nil. Returns {:ok, notification} or {:error, reason}.

Functions

defaults()

Returns the default values for all Notification fields.

These defaults match the exact values currently used in prepare_notification/1.

Required fields (per Mastodon OpenAPI spec):

  • id: The notification ID
  • type: Type of notification (follow, mention, reblog, favourite, etc.)
  • created_at: Timestamp of the notification
  • account: Account that caused the notification

Optional fields:

  • status: Associated status (for mention, reblog, favourite, poll, status types)

new(overrides \\ %{})

Returns a new Notification map with default values. Can optionally merge custom values via the overrides parameter.

Examples

iex> Notification.new(%{"id" => "123", "type" => "follow"})
%{"id" => "123", "type" => "follow", "created_at" => nil, ...}

required_fields()

List of required fields per the Mastodon OpenAPI specification.

valid_types()

List of valid notification types per the Mastodon API spec.

validate(notification)

Validates that all required fields are present and non-nil. Returns {:ok, notification} or {:error, reason}.