PhoenixKit.Modules.Connections.Block (phoenix_kit v1.7.42)

Copy Markdown View Source

Schema for user blocking relationships.

Represents a one-way block where one user blocks another. Blocking prevents all interaction between users.

Fields

  • blocker_uuid - UUID of the user who initiated the block
  • blocked_uuid - UUID of the user who is blocked
  • blocker_id - Integer ID (deprecated, dual-write only)
  • blocked_id - Integer ID (deprecated, dual-write only)
  • reason - Optional reason for the block (visible to admins)
  • inserted_at - When the block was created

Examples

# User A blocks User B
%Block{
  uuid: "018e3c4a-9f6b-7890-abcd-ef1234567890",
  blocker_uuid: "019abc12-3456-7890-abcd-ef1234567890",
  blocked_uuid: "019abc12-9876-5432-abcd-ef1234567890",
  reason: "Spam",
  inserted_at: ~N[2025-01-15 10:30:00]
}

Business Rules

  • Cannot block yourself
  • Blocking removes any existing follows between the users
  • Blocking removes any existing connections between the users
  • Blocked users cannot follow, connect, or view the blocker's profile
  • Blocking is one-way (A blocks B doesn't mean B blocks A)

Summary

Functions

Changeset for creating a block.

Types

t()

@type t() :: %PhoenixKit.Modules.Connections.Block{
  __meta__: term(),
  blocked: PhoenixKit.Users.Auth.User.t() | Ecto.Association.NotLoaded.t(),
  blocked_id: integer() | nil,
  blocked_uuid: UUIDv7.t(),
  blocker: PhoenixKit.Users.Auth.User.t() | Ecto.Association.NotLoaded.t(),
  blocker_id: integer() | nil,
  blocker_uuid: UUIDv7.t(),
  inserted_at: NaiveDateTime.t() | nil,
  reason: String.t() | nil,
  uuid: UUIDv7.t() | nil
}

Functions

changeset(block, attrs)

Changeset for creating a block.

Required Fields

  • blocker_uuid - UUID of the user who is blocking
  • blocked_uuid - UUID of the user being blocked

Optional Fields

  • reason - Why the user was blocked
  • blocker_id - Integer ID (deprecated, dual-write)
  • blocked_id - Integer ID (deprecated, dual-write)

Validation Rules

  • Both user UUIDs are required
  • Cannot block yourself
  • Unique constraint on (blocker_uuid, blocked_uuid) pair