PhoenixKit.Modules.Publishing.Shared (PhoenixKitPublishing v0.4.6)

Copy Markdown View Source

Shared helper functions used across publishing submodules.

These functions were extracted to eliminate duplication between Posts, Versions, TranslationManager, and Groups.

Summary

Functions

Like actor_uuid_from_socket/1 but for a template's assigns map.

Reads the current user's UUID from a LiveView socket's phoenix_kit_current_scope assign. Returns nil when the LV is mounted in a logged-out context (no scope, no user). LV callers thread the result into mutating context functions as actor_uuid: actor_uuid_from_socket(socket) so the activity log records who initiated the change.

Reads a post back from DB using the appropriate method for the post's mode.

Functions

actor_uuid_from_assigns(arg1)

Like actor_uuid_from_socket/1 but for a template's assigns map.

actor_uuid_from_socket(arg1)

@spec actor_uuid_from_socket(struct() | map() | any()) :: String.t() | nil

Reads the current user's UUID from a LiveView socket's phoenix_kit_current_scope assign. Returns nil when the LV is mounted in a logged-out context (no scope, no user). LV callers thread the result into mutating context functions as actor_uuid: actor_uuid_from_socket(socket) so the activity log records who initiated the change.

read_back_post(group_slug, identifier, db_post, language, version_number)

@spec read_back_post(
  String.t(),
  term(),
  term() | nil,
  String.t() | nil,
  pos_integer() | nil
) ::
  {:ok, map()} | {:error, :not_found}

Reads a post back from DB using the appropriate method for the post's mode.

Used after create/update operations to return a consistent post map.