Skip to main content
The friend system manages relationships between users, including friend requests, accepted friendships, and blocking.

Overview

The tangle.client.friends package provides functionality for managing user relationships, syncing platform friends, and handling friend requests.

Getting Relationships

Retrieve all relationships for the current user.

GetRelationships

This message requests all relationships for the authenticated user.
// friends.getRelationships -> Relationships
message GetRelationships {}
This message has no parameters. The server returns relationships for the authenticated user.

Response: Relationships

The server responds with a Relationships message containing relationship data and associated user information.
relationships
types.Relationship[]
required
Array of all relationships for the current user
users
types.User[]
required
Array of user objects for all users involved in the relationships

Protocol Definition

message Relationships {
  repeated types.Relationship relationships = 1;
  repeated types.User users = 2;
}

Changing Relationships

Modify the relationship status with another user.

ChangeRelationship

user
refs.UserRef
required
Reference to the user to change the relationship with
change
RelationshipChangeType
required
The type of relationship change to perform

Protocol Definition

// friends.changeRelationship -> ()
message ChangeRelationship {
  refs.UserRef user = 1;
  RelationshipChangeType change = 2;

  enum RelationshipChangeType {
    INVALID = 0;
    REQUEST_FRIEND = 1;
    ACCEPT_FRIEND = 2;
    REMOVE_FRIEND = 3;
    BLOCK = 4;
    UNBLOCK = 5;
  }
}

Relationship Change Types

The RelationshipChangeType enum defines the possible relationship operations.
INVALID
0
Invalid/default value, should not be used
REQUEST_FRIEND
1
Send a friend request to the specified user
ACCEPT_FRIEND
2
Accept an incoming friend request from the specified user
REMOVE_FRIEND
3
Remove an existing friendship or cancel an outgoing friend request
BLOCK
4
Block the specified user
UNBLOCK
5
Unblock the specified user

Syncing Platform Friends

The SyncFriends message allows synchronizing friends from external platforms.

SyncFriends

platform_user_id
string
required
User’s ID on the external platform
hashed_platform_user_id
bytes
required
Hashed version of the platform user ID for privacy
platform_user_name
string
Optional username on the external platform
platform
string
required
Name/identifier of the external platform
friend_ids_hashed
bytes[]
required
Array of hashed friend IDs from the platform
community_ids_hashed
bytes[]
required
Array of hashed community/server IDs from the platform

Protocol Definition

// friends.syncFriends -> ()
message SyncFriends {
  string platform_user_id = 1;
  bytes hashed_platform_user_id = 2;
  optional string platform_user_name = 3;
  string platform = 4;
  repeated bytes friend_ids_hashed = 5;
  repeated bytes community_ids_hashed = 6;
}
The sync friends functionality uses hashed IDs to protect user privacy while enabling cross-platform friend discovery.

Common Workflows

Sending a Friend Request

  1. Send ChangeRelationship with change set to REQUEST_FRIEND
  2. The target user receives a friend request
  3. The relationship status updates to reflect the pending request

Accepting a Friend Request

  1. Receive notification of incoming friend request
  2. Send ChangeRelationship with change set to ACCEPT_FRIEND
  3. Both users’ relationship status updates to friends

Removing a Friend

  1. Send ChangeRelationship with change set to REMOVE_FRIEND
  2. The friendship is terminated
  3. Both users’ relationship status updates

Blocking a User

  1. Send ChangeRelationship with change set to BLOCK
  2. The user is blocked
  3. Any existing friendship is removed
  4. Communication from the blocked user is filtered

Best Practices

  • Always fetch current relationships with GetRelationships before displaying the friends list
  • Handle relationship updates from the server to keep the UI synchronized
  • Use appropriate confirmation dialogs before blocking or removing friends
  • Validate user references before sending relationship change requests

Build docs developers (and LLMs) love