How to get the number of unread messages for user from synapse server via API - matrix-synapse

How can the number of unread messages (or events) for a specific user be retrieved from a matrix synapse server via API?
Via the synapse admin or the matrix client-server API.
Events seem to be a complex topic.
Thanks a lot!

Two solutions:
https://spec.matrix.org/v1.1/client-server-api/#get_matrixclientv3notifications returns only unread notifications
https://spec.matrix.org/v1.1/client-server-api/#get_matrixclientv3sync returns the number of unread notifications for each room the user is a member: "org.matrix.msc2654.unread_count": 0

Related

Getting Total unread messages count in Twilio Conversations

we're using Twilio Conversations to power 1-to-1 chat for a webapp. I see that the unreadMessagesCount implemented via Read Horizon can indicate the number of unread messages in a particular conversation for a participant.
My question: Is there a way to get the total unread messages for ALL of a user's ongoing conversations? E.g., if a user has 3 ongoing conversations that each have 5 unread messages, I would like to provide the user with an badge showing they have 15 unread messages (i.e., the customary user experience using messaging apps).
Would we have to loop through all the conversations that a user is a participant of and call unreadMessagesCount for each? If so, have some concern if that would bog down performance too much as some users could be a participant to a large number of conversations.
If total count of unread messages in all conversations is not able to be implemented efficiently, would also be fine if could just identify the total number of 1-on-1 conversations that have 1+ unread messages. But have not found a way to do this either.
Appreciate any thoughts on the best way to implement this.

FCM, How to make all users in group to subscribe to topic

I'm making a social media app like Facebook using Flutter and Firebase.
I'm using Firebase Cloud Messaging to make notification service.
I want to make users who joined community or groups to subscribe their group's topic. Therefore, I can send notification to them by using method which is "subscribeToTopic()". However, I don't know how to make all users in community or groups to subscribe to certain topics.
If you know how to make all users to subscribe to certain topics, please let me know. Thank you!
There is no API to get the current subscribers to a topic, nor is there an API that verbatim subscribes all subscribers to one topic to another topic.
If you already track group membership yourself, you can either let each client subscriber themselves to the additional topic, or you can determine the list of tokens for the group members and then subscribe them to the topic on the server.

Queue used in whatsapp or FB Messenger

While thinking through a system design for real-time chat, I am curious what kind queue whatsapp or FB messenger is using on Server side to deliver the message to recipient. What I was thinking was there is a per-person queue/kafka-topic, so when a new message need to be deliver to user A, the message is enqueue to A's queue.
However, there may be billions of users (FB has 2 billion users), does that mean we need 2 billion queues/topics(in kafka term)? If so, which queue can handle this performantly.
Any comment is welcome!
Thank you!

How to manage PubSub notifications send while offline in XMPP?

How to get offline message in PubSub? Using the Smack library. after searching I found an answer which looks like this:
// Create a pubsub manager using an existing XMPPConnection
PubSubManager mgr = PubSubManager.getInstanceFor(con);
// Get the node
LeafNode node = mgr.getNode("testNode");
List<? extends Item> items = node.getItems(100);
But node.getItems(100) returns last 100 messages, which can be online and offline too.
1) how to keep track of online and offline message in pubsub using smack?
2) is it possible to get unread message count in pubsub using smack? if yes then how to achieve it?
3) how to know that who(publisher) send this message in a node?
I just went through the documentation of Smack and PubSub from here
and here but didn't find the solutions related to my queries. So can anyone help me to solve this?
1) how to keep track of online and offline message in pubsub using
smack?
I would suggest using the PubSub item ID.
2) is it possible to get unread message count in pubsub using smack?
if yes then how to achieve it?
PubSub nodes don't have a per subscribed unread message count.
If you want to catch-up on all new items since you received the last item from a PubSub node, you'd usually remember the last item's ID and use that to query for all newer items on the PubSub node. Unfortunately there is (currently) no way to query a PubSub node for newer items after a certain ID.
But if you are subscribed to a node, then the service will notify you about new items even if you are offline. And if your server stores those offline messages for you, then you will receive them eventually.
3) how to know that who(publisher) send this message in a node?
Unfortunately there is no reliable way to the the JID of the entity which published an item. This too, could probably be fixed with an extension XEP.

MAM XEP-0313 - Query conversation list for a particular user

I am developing a mobile messaging app (ios) and I support the logout feature. I want to keep the latest conversation list when the users logs in back again. Because the local storage of the app gets cleaned once logout.
I am using MAM XEP-0313 sucessfully but I have not found an IQ to query the conversation list of a particular user.
For example:
chat
user_a -> user_b
user_c
user_d
user_f
user_a has had conversations with 4 users and he wants to logout of the app, when he comes back in he needs to get those last 4 conversation threads on his list.
What I do when a user messages another user is that I add them to my roster and have the logic of automatic subscription. So I was thinking to use the roster history logic to query this collection but I was also expecting the MAM module to have a more direct way..
I am using MongooseIM server
I understand your problem, the solution you have is probably the best one you can have with standard XEPs and their implementations.
The conversation list is actually sth missing in MAM spec or in general in XMPP. There are some works to define an extension to get you all the conversations where you have some unread messages (so called "unread sync"). Will this be enough for you or you would rather want to get some kind of "inbox". By "inbox" I mean a list of all recent conversations with unread messages count where there are some unread messages.