How to implement a list of chats with XMPP
Asked Answered
A

1

2

I have Ejabberd server and mobile iOS/Android apps.

I want to build a simple Chat app with something like 2 screens:

  • List of chats
  • Screen with messages of particular chat

I have an issue with the List of chats implementation. I use XEP-0313: Message Archive Management to store chat history and it suites very well for my 2nd screen - screen with messages of particular chat.

But I can't find a proper way to show a list of chats

I have an idea to merge all user's contacts (roster) + group rooms and then show, but users do not have active chats with all their contacts so this is not a right solution.

It's also good to show a last message text along with each chat on a list of chats screen. So this is a pretty standard feature in all modern messengers.

Is it possible to do with any XEPs? or maybe I can use a Message Archive XEP in some way

Some thoughts here Get last message of each conversation with XEP-0313?, but still no answer

Anissaanita answered 29/8, 2018 at 20:11 Comment(5)
Do you use local storage like SQLite database? What is difference between chatlist and current chats? Is it time difference or something more?Dellinger
I use SQLite, but I want it to be accessible from all of my devices, so the same data should be on the Chats screen across all of my devices.Anissaanita
@KenanBegić what do you mean by "between chatlist and current chats". We can call it as you wish, it's just a list of all users chatsAnissaanita
@Rubycon, this is a great question. Did you find an answer or a workaround?Sparkle
@Sparkle I ended up with building an external API endpoint to get it all and provide to user. This endpoint can access Ejabberd DBAnissaanita
U
0

But I can't find a proper way to show a list of chats

List of rooms where a particular account is occupant (has joined):

$ ejabberdctl get_user_rooms user1 localhost
[email protected]
[email protected]
Urinary answered 30/8, 2018 at 10:11 Comment(4)
This is right regarding group chats, but user may have also 1-1 chats. How can I get a list of 1-1 chats ?Anissaanita
You can know which messages a user has sent to another one, or has received from another ones, by looking in the MAM archive. Other than that, the server keeps no more information.Urinary
Well, this is not good. Let's say I have 30 chats, so it means I need to do 30 request to MAM on start app to render list of chats screen. I want to omit it. I want to limit it to a couple of requests on start app and then when a user goes to particular chat - check MAM of chat chat. Anything like this is possible?Anissaanita
do you have nay advises here?Anissaanita

© 2022 - 2024 — McMap. All rights reserved.