User connections module — social relationships system.
Provides a complete social relationships system with two types of relationships:
- Follows - One-way relationships (User A follows User B, no consent needed)
- Connections - Two-way mutual relationships (both users must accept)
Plus blocking functionality to prevent unwanted interactions.
Usage Examples
In a User Profile Page
# Get relationship for rendering follow/connect buttons
relationship = PhoenixKitUserConnections.get_relationship(current_user, profile_user)
# Display counts
followers = PhoenixKitUserConnections.followers_count(profile_user)
following = PhoenixKitUserConnections.following_count(profile_user)
connections = PhoenixKitUserConnections.connections_count(profile_user)Business Rules
Following
- Cannot follow yourself
- Cannot follow if blocked (either direction)
- Instant, no approval needed
Connections
- Cannot connect with yourself
- Cannot connect if blocked
- Requires acceptance from recipient
- If A requests B while B has pending request to A → auto-accept both
Blocking
- Blocking removes any existing follow/connection between the users
- Blocked user cannot follow, connect, or view profile
- Blocking is one-way (A blocks B doesn't mean B blocks A)
Summary
Functions
Accepts a pending connection request.
Blocks a user. Blocking removes any existing follows and connections.
Checks if user A has blocked user B.
Checks if user is blocked by other user.
Returns the count of users blocked by a user.
Checks if two users can interact (neither has blocked the other).
Cancels a pending outgoing connection request.
Checks if two users are connected (mutual connection exists).
Returns the count of connections for a user.
Creates a follow relationship.
Returns the count of followers for a user.
Checks if user A is following user B.
Returns the count of users that a user is following.
Gets the full relationship status between two users in one call.
Returns statistics for the admin overview page.
Returns all users blocked by a user.
Returns all connections for a user.
Returns all followers of a user.
Returns all users that a user is following.
Returns pending incoming connection requests for a user.
Returns pending outgoing connection requests sent by a user.
Returns the count of pending incoming connection requests for a user.
Rejects a pending connection request.
Removes an existing connection between two users.
Sends a connection request from requester to recipient.
Removes a block.
Removes a follow relationship.
Functions
Accepts a pending connection request.
Blocks a user. Blocking removes any existing follows and connections.
Checks if user A has blocked user B.
Checks if user is blocked by other user.
Returns the count of users blocked by a user.
Checks if two users can interact (neither has blocked the other).
Cancels a pending outgoing connection request.
Checks if two users are connected (mutual connection exists).
Returns the count of connections for a user.
Creates a follow relationship.
User A follows User B. No consent is required from User B.
Returns the count of followers for a user.
Checks if user A is following user B.
Returns the count of users that a user is following.
Gets the full relationship status between two users in one call.
Returns statistics for the admin overview page.
Returns all users blocked by a user.
Returns all connections for a user.
Returns all followers of a user.
Returns all users that a user is following.
Returns pending incoming connection requests for a user.
Returns pending outgoing connection requests sent by a user.
Returns the count of pending incoming connection requests for a user.
Rejects a pending connection request.
Removes an existing connection between two users.
Sends a connection request from requester to recipient.
If recipient already has a pending request to requester, both requests are automatically accepted.
Removes a block.
Removes a follow relationship.