PhoenixKit.Modules.Posts.PostMention (phoenix_kit v1.7.62)

Copy Markdown View Source

Schema for post mentions (tagged users).

Tags users related to a post - either as contributors who helped create it, or mentions of people featured in the content.

Mention Types

  • contributor - User helped create/contribute to the post
  • mention - User is mentioned/tagged in the post

Fields

  • post_uuid - Reference to the post
  • user_uuid - Reference to the mentioned user
  • mention_type - contributor/mention

Examples

# Contributor mention
%PostMention{
  post_uuid: "018e3c4a-9f6b-7890-abcd-ef1234567890",
  user_uuid: "018e3c4a-1234-5678-abcd-ef1234567890",
  mention_type: "contributor"
}

# Regular mention
%PostMention{
  post_uuid: "018e3c4a-9f6b-7890-abcd-ef1234567890",
  user_uuid: "018e3c4a-5678-1234-abcd-ef1234567890",
  mention_type: "mention"
}

Summary

Functions

Changeset for creating or updating a mention.

Check if mention is a contributor.

Types

t()

@type t() :: %PhoenixKit.Modules.Posts.PostMention{
  __meta__: term(),
  inserted_at: DateTime.t() | nil,
  mention_type: String.t(),
  post: PhoenixKit.Modules.Posts.Post.t() | Ecto.Association.NotLoaded.t(),
  post_uuid: UUIDv7.t(),
  updated_at: DateTime.t() | nil,
  user: PhoenixKit.Users.Auth.User.t() | Ecto.Association.NotLoaded.t(),
  user_uuid: UUIDv7.t() | nil,
  uuid: UUIDv7.t() | nil
}

Functions

changeset(mention, attrs)

Changeset for creating or updating a mention.

Required Fields

  • post_uuid - Reference to post
  • user_uuid - Reference to mentioned user
  • mention_type - Must be: "contributor" or "mention"

Validation Rules

  • Mention type must be valid (contributor/mention)
  • Unique constraint on (post_uuid, user_uuid) - one mention per user per post

contributor?(arg1)

Check if mention is a contributor.