GamendWeb.Serializers (gamend_web v1.0.1215)

Copy Markdown View Source

Shared JSON payload serializers used by API controllers and channels.

Null policy

String-typed fields are never null — an unset value serializes as "". Game clients (Godot in particular) choke on null where they expect a string. Datetimes, numbers and objects keep null where absence is semantic (e.g. ends_at: null = permanent).

Summary

Functions

display_name(user_id)

@spec display_name(integer() | nil) :: String.t()

serialize_chat_message(message, opts \\ [])

@spec serialize_chat_message(term(), keyword()) :: map()

serialize_group(group, opts \\ [])

@spec serialize_group(term(), keyword()) :: map()

serialize_lobby(lobby, opts \\ [])

@spec serialize_lobby(term(), keyword()) :: map()

serialize_notification(notification)

@spec serialize_notification(term()) :: map()

serialize_party(party, opts \\ [])

@spec serialize_party(term(), keyword()) :: map()

serialize_quest_progress(progress)

@spec serialize_quest_progress(term()) :: map()

serialize_ready_check(check, opts \\ [])

@spec serialize_ready_check(term(), keyword()) :: map() | nil

Serializes a ready check for its participants.

A "ready" check lists every participant and their state — lobby members already see each other. An "accept" check returns counts and the viewer's own state only: a match that may still dissolve should not reveal who the player was paired with.