Overview
Thetangle.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.This message has no parameters. The server returns relationships for the authenticated user.
Response: Relationships
The server responds with aRelationships message containing relationship data and associated user information.
Array of all relationships for the current user
Array of user objects for all users involved in the relationships
Protocol Definition
Changing Relationships
Modify the relationship status with another user.ChangeRelationship
Reference to the user to change the relationship with
The type of relationship change to perform
Protocol Definition
Relationship Change Types
TheRelationshipChangeType enum defines the possible relationship operations.
Invalid/default value, should not be used
Send a friend request to the specified user
Accept an incoming friend request from the specified user
Remove an existing friendship or cancel an outgoing friend request
Block the specified user
Unblock the specified user
Syncing Platform Friends
TheSyncFriends message allows synchronizing friends from external platforms.
SyncFriends
User’s ID on the external platform
Hashed version of the platform user ID for privacy
Optional username on the external platform
Name/identifier of the external platform
Array of hashed friend IDs from the platform
Array of hashed community/server IDs from the platform
Protocol Definition
The sync friends functionality uses hashed IDs to protect user privacy while enabling cross-platform friend discovery.
Common Workflows
Sending a Friend Request
- Send
ChangeRelationshipwithchangeset toREQUEST_FRIEND - The target user receives a friend request
- The relationship status updates to reflect the pending request
Accepting a Friend Request
- Receive notification of incoming friend request
- Send
ChangeRelationshipwithchangeset toACCEPT_FRIEND - Both users’ relationship status updates to friends
Removing a Friend
- Send
ChangeRelationshipwithchangeset toREMOVE_FRIEND - The friendship is terminated
- Both users’ relationship status updates
Blocking a User
- Send
ChangeRelationshipwithchangeset toBLOCK - The user is blocked
- Any existing friendship is removed
- Communication from the blocked user is filtered
Best Practices
- Always fetch current relationships with
GetRelationshipsbefore 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