Schema for user posts with media attachments.
Represents a social post with type-specific layouts, privacy controls, and scheduled publishing support.
Post Types
- post - Standard full post with full content and media gallery
- snippet - Short form post with truncated display
- repost - Share of external content with source attribution
Status Flow
draft- Post is being edited (not visible to others)public- Post is published and visible to allunlisted- Post is accessible via direct link but not in feedsscheduled- Post will be auto-published at scheduled_at time
Fields
user_uuid- Owner of the posttitle- Post title (max length via settings)sub_title- Subtitle/tagline (max length via settings)content- Post content (max length via settings)type- post/snippet/repost (affects display layout)status- draft/public/unlisted/scheduledscheduled_at- When to auto-publish (nullable)published_at- When made public (nullable)repost_url- Source URL for reposts (nullable)slug- SEO-friendly URL sluglike_count- Denormalized counter (updated via context)comment_count- Denormalized counter (updated via context)view_count- Page views counter (updated via context)metadata- Type-specific flexible data (JSONB)
Examples
# Standard post
%Post{
id: "018e3c4a-9f6b-7890-abcd-ef1234567890",
user_uuid: "018e3c4a-1234-5678-abcd-ef1234567890",
title: "My First Post",
sub_title: "An introduction to my journey",
content: "This is the full content...",
type: "post",
status: "public",
slug: "my-first-post",
like_count: 42,
comment_count: 15,
view_count: 523,
published_at: ~U[2025-01-01 12:00:00Z]
}
# Scheduled post
%Post{
title: "Future Announcement",
content: "...",
type: "post",
status: "scheduled",
scheduled_at: ~U[2025-12-31 09:00:00Z],
published_at: nil
}
# Repost
%Post{
title: "Great Article",
content: "Check this out!",
type: "repost",
status: "public",
repost_url: "https://example.com/article",
metadata: %{"original_author" => "Jane Doe"}
}
Summary
Functions
Check if post can receive comments (public or unlisted).
Changeset for creating or updating a post.
Check if post is a draft.
Check if post is published (public or unlisted).
Check if post is a repost type.
Check if post is scheduled for future publishing.
Types
@type t() :: %PhoenixKit.Modules.Posts.Post{ __meta__: term(), comment_count: integer(), comments: [PhoenixKit.Modules.Posts.PostComment.t()] | Ecto.Association.NotLoaded.t(), content: String.t(), dislike_count: integer(), dislikes: [PhoenixKit.Modules.Posts.PostDislike.t()] | Ecto.Association.NotLoaded.t(), groups: [PhoenixKit.Modules.Posts.PostGroup.t()] | Ecto.Association.NotLoaded.t(), inserted_at: DateTime.t() | nil, like_count: integer(), likes: [PhoenixKit.Modules.Posts.PostLike.t()] | Ecto.Association.NotLoaded.t(), media: [PhoenixKit.Modules.Posts.PostMedia.t()] | Ecto.Association.NotLoaded.t(), mentions: [PhoenixKit.Modules.Posts.PostMention.t()] | Ecto.Association.NotLoaded.t(), metadata: map(), published_at: DateTime.t() | nil, repost_url: String.t() | nil, scheduled_at: DateTime.t() | nil, slug: String.t(), status: String.t(), sub_title: String.t() | nil, tags: [PhoenixKit.Modules.Posts.PostTag.t()] | Ecto.Association.NotLoaded.t(), title: String.t(), type: String.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, view_count: integer() }
Functions
Check if post can receive comments (public or unlisted).
Changeset for creating or updating a post.
Required Fields
user_uuid- Owner of the posttitle- Post titlecontent- Post contenttype- Must be: "post", "snippet", or "repost"status- Must be: "draft", "public", "unlisted", or "scheduled"
Validation Rules
- Title and content lengths validated against settings
- Type must be valid (post/snippet/repost)
- Status must be valid (draft/public/unlisted/scheduled)
- Slug auto-generated from title if not provided
- Scheduled posts must have scheduled_at
- Reposts should have repost_url
Check if post is a draft.
Check if post is published (public or unlisted).
Check if post is a repost type.
Check if post is scheduled for future publishing.