Friends list sync from your website #43

Open
opened 2024-03-09 21:31:21 +00:00 by kirsle · 0 comments

If you use BareRTC with a social networking website, it would be nice if friend list information could be synced to the chat room. It should be scalable though in case a given user has 10,000 friends on your site, so methods of having your site sync over 10,000 usernames before they join the chat room (the way the blocklist sync endpoint works) may not be a good fit.

If there are only ever a ~couple hundred chatters online at any given time, a more streamlined system to query friendships among only that subset of users may be good. It could be handled by a webhook URL to your site that the BareRTC server can call periodically and/or cache.

The webhook could be a POST request coming from BareRTC where it sends a list of users currently online:

{
  "usernames": [ "alice", "bob", "carlos", "dave", "eve" ]
}

And it could expect a JSON response containing friendship sets between those users, like:

{
  "friendships": {
    "alice": [ "bob", "carlos" ],
    "bob": [ "alice", "dave" ],
    "carlos": [ "alice" ],
    "dave": [ "bob" ],
    "eve": []
  }
}

Open questions:

  • When should it make this request? Every time someone joins the chat? On an interval, unless we have a complete cache for the current list of chat users?
  • Or should this be more client-side driven?
    • A user joins chat, makes an ajax request to BareRTC for their friendships, it proxies thru to your website to gather the list of chatters online who are their friends and returns it, their chat front-end page caches it and marks users as friends.
    • When new people join the chat, their front-end page would make followup requests to check if those users are their friends too, to update the front-end cache.
    • Pros: a user always knows a new joiner is their friend quickly without waiting on a server-side cache refresh interval.
If you use BareRTC with a social networking website, it would be nice if friend list information could be synced to the chat room. It should be scalable though in case a given user has 10,000 friends on your site, so methods of having your site sync over 10,000 usernames before they join the chat room (the way the blocklist sync endpoint works) may not be a good fit. If there are only ever a ~couple hundred chatters online at any given time, a more streamlined system to query friendships among only that subset of users may be good. It could be handled by a webhook URL to your site that the BareRTC server can call periodically and/or cache. The webhook could be a POST request coming from BareRTC where it sends a list of users currently online: ```json { "usernames": [ "alice", "bob", "carlos", "dave", "eve" ] } ``` And it could expect a JSON response containing friendship sets between those users, like: ```json { "friendships": { "alice": [ "bob", "carlos" ], "bob": [ "alice", "dave" ], "carlos": [ "alice" ], "dave": [ "bob" ], "eve": [] } } ``` Open questions: * When should it make this request? Every time someone joins the chat? On an interval, unless we have a complete cache for the current list of chat users? * Or should this be more client-side driven? * A user joins chat, makes an ajax request to BareRTC for their friendships, it proxies thru to your website to gather the list of chatters online who are their friends and returns it, their chat front-end page caches it and marks users as friends. * When new people join the chat, their front-end page would make followup requests to check if those users are their friends too, to update the front-end cache. * Pros: a user always knows a new joiner is their friend _quickly_ without waiting on a server-side cache refresh interval.
kirsle added the
enhancement
label 2024-03-09 21:31:21 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: apps/BareRTC#43
There is no content yet.