PhoenixKitUserConnections

Social relationships module for PhoenixKit — follows, mutual connections, and blocking.

Features

Installation

Add to your mix.exs dependencies:

{:phoenix_kit_user_connections, "~> 0.5"}

Requires phoenix_kit 3.10.0 or later (any core 3.x).

The module is auto-discovered by PhoenixKit at startup — no additional configuration needed. Run mix phoenix_kit.update after adding or upgrading it: the module owns its tables' migration chain (PhoenixKitUserConnections.Migrations), which runs after core's.

Enable the module from the admin Modules page (or PhoenixKitUserConnections.enable_system/0); its admin statistics page is /admin/connections under your PhoenixKit URL prefix. The user-facing page, PhoenixKitUserConnections.Web.UserConnections, is not routed by the module: mount it at /profile/connections under the same prefix (PhoenixKit.Utils.Routes.path("/profile/connections")), inside PhoenixKit's authenticated live_session. Its tab links patch to that path, so it breaks anywhere else.

Usage

# Follow a user
PhoenixKitUserConnections.follow(current_user, other_user)

# Request a mutual connection
PhoenixKitUserConnections.request_connection(current_user, other_user)

# Accept a connection request (only its recipient may; anyone else gets
# {:error, :not_recipient}). reject_connection/2 takes the same arguments.
PhoenixKitUserConnections.accept_connection(current_user, connection)

# Block a user (removes existing follows/connections)
PhoenixKitUserConnections.block(current_user, other_user, "reason")

# Get full relationship status
PhoenixKitUserConnections.get_relationship(current_user, other_user)
# => %{following: true, followed_by: false, connected: false, ...}

Business Rules

License

MIT — see LICENSE.