Addition of a new feature module

59 views
Skip to first unread message

Ou Yuan

unread,
Sep 28, 2025, 10:40:30 PM (2 days ago) Sep 28
to Tinode General

I have implemented a new feature module called "moment". Its core function is to subscribe to and broadcast user "psp topics".

My current approach is to add a new message body type to the existing client-side messages. For example:

JSON
{ "moment": { "id": "82914", "topic": "me", "op": "get(update, del, ...)", "data": { "limit": 10, "since": 123, ... } } }

Next, I handle the business logic in session.go (which calls store.go's adapter for data persistence). I then use sub.meta <- msg for message broadcasting. The broadcast logic itself is written in topic.go within the handleMoment function. For instance, when someone publishes a "moment", it gets broadcast to the relevant "psp" users.

Additionally, I've added a new access control permission "V" in types.go's AccessMode to verify if a subscribing user is authorized to view my moments.

Is this a reasonable approach?

Gene

unread,
Sep 29, 2025, 2:31:28 AM (2 days ago) Sep 29
to Tinode General
What is a "moment"?

Ou Yuan

unread,
Sep 29, 2025, 2:43:20 AM (2 days ago) Sep 29
to Tinode General
  A "moment" is a type of journal entry where users record information about something that happened at a specific point in time. Moments are submitted by the user and can then be viewed by their subscribers.  

Gene

unread,
Sep 29, 2025, 3:19:36 AM (2 days ago) Sep 29
to Tinode General
So, it's like telegram/instagram stories or whatsapp status? If so, i would do it differently. Depending on the exact features, I would do it either as one new topic per user (like 'slf') or two topics (one for publishing, one for reading). I would definitely not create a new message type.

Ou Yuan

unread,
Sep 29, 2025, 6:50:43 AM (2 days ago) Sep 29
to Tinode General
  Thank you for your reply. So, my current approach is also acceptable, right? I'm asking because I noticed the original project already has mutually subscribed p2p topics, so I was planning to use that as a base to extend a feature similar to Stories.  

Gene

unread,
Sep 29, 2025, 10:54:00 AM (2 days ago) Sep 29
to Tinode General
On Monday, September 29, 2025 at 1:50:43 PM UTC+3 Ou Yuan wrote:
  Thank you for your reply. So, my current approach is also acceptable, right?

I don't know. All I see is a description of a new message type. As I said before, I would not do it this way. But it's your code.
 
I'm asking because I noticed the original project already has mutually subscribed p2p topics, so I was planning to use that as a base to extend a feature similar to Stories.  

Stories are not one-to-one. They are one-to-many and as such they are more like channels or maybe like a 'me' topic.
Reply all
Reply to author
Forward
0 new messages