ejabberd icon indicating copy to clipboard operation
ejabberd copied to clipboard

How to get the current date for created_at when create a Multi-User Chat.

Open vietnguyen87 opened this issue 10 months ago • 21 comments

I created a room with API https://docs.ejabberd.im/archive/24_02/admin-api/#create-room-with-opts . But column created_at in table muc_room was not getting the current date.

image

Help me fix this. Please.

vietnguyen87 avatar Apr 16 '24 08:04 vietnguyen87

This column got repurposed, and now it keeps info about date of room hibernation (or sentinel value of 1970 when room is alive).

prefiks avatar Apr 16 '24 08:04 prefiks

So what you see here is correct behaviour per current code.

prefiks avatar Apr 16 '24 08:04 prefiks

In case I want to know when this room was created, where can I get it? @prefiks

vietnguyen87 avatar Apr 16 '24 08:04 vietnguyen87

You can't any more.

prefiks avatar Apr 16 '24 09:04 prefiks

By the way, can you tell me? Can I get a list of members in the room with their roles via admin api ?

vietnguyen87 avatar Apr 16 '24 09:04 vietnguyen87

You probably could use ejabberdctl get_room_occupants room conference.server.com. It require mod_muc_admin module enabled in config. Docs here: https://docs.ejabberd.im/developer/ejabberd-api/admin-api/#get-room-occupants

prefiks avatar Apr 16 '24 09:04 prefiks

yes, i got it. But i get nothing when user disconnect.

vietnguyen87 avatar Apr 16 '24 09:04 vietnguyen87

So you don't want to see roles but what affiliations are stored in a room (roles are only set for online users). Check https://docs.ejabberd.im/developer/ejabberd-api/admin-api/#get-room-affiliations

prefiks avatar Apr 16 '24 10:04 prefiks

Yeah, thanks so much. I also get another issue. Please help me. When i join a room or send a message, it's created many chat records in archive for all users in room like the image below. kind = chat and txt is empty. Please see last 4 records. this room have 3 members. i connect with user 1 (owner) and user 2, user 3 are members.

image

Please....

vietnguyen87 avatar Apr 16 '24 10:04 vietnguyen87

What those messages contain? Could you expand xml of one of those?

They look like messages to individual room member (and not sent to all members of a room), and as such are stored in sender and recipient archive.

prefiks avatar Apr 16 '24 10:04 prefiks

It's full description in xml. this room have 3 members.

Screenshot 2024-04-16 at 17 43 51

vietnguyen87 avatar Apr 16 '24 10:04 vietnguyen87

This message have type "chat" so it's handled like regular message between two peers (as it in fact is), so it get stored in recipient and sender archive. What do you expect to happen with those message, they never get stored?

prefiks avatar Apr 16 '24 10:04 prefiks

But obviously I sent it to the room as a groupchat kind. and i understand everybody in this room will received it. I think it needs content saved in txt and kind is groupchat.

Suppose I want to get the chat history of user3 in room2 from the last message at (timestamp). How can i do it?

vietnguyen87 avatar Apr 16 '24 10:04 vietnguyen87

Ah, those are mucsub events that are generated for muc messages. This is how mucsub works, it notifies subscribers that aren't in room, by sending those. And those message are allowed to be stored in archive or offline storage, because this is only way that offline user can know about those.

prefiks avatar Apr 16 '24 11:04 prefiks

thanks @prefiks. Let's me clarify something

  1. Multi User Chat in XMPP is presence based. When you are online you get the message. When you get offline, you leave the room and will not get anymore message until you join the room again by sending a presence message. The only way that offline user can receive message is use MUC/Sub protocol to subscribe to chat rooms. And those message are allowed to be stored in archive or offline storage like a message between two peers.
  2. To get history of user from the last message at (timestamp) in MUC/Sub i have to parse the xml column, right? in case, taking full control of the message management on the client side.

vietnguyen87 avatar Apr 16 '24 15:04 vietnguyen87

Generally you don't need to parse anything, as there is already code in ejabberd that handles all this in mod_mam module, that respond to request described in https://xmpp.org/extensions/xep-0313.html.

Are you trying add external management of those outside ejabberd?

prefiks avatar Apr 16 '24 15:04 prefiks

I'm talking with ejabberd by golang. and clients (Web/App) connect with Chat Service (golang) and use go xmpp library https://pkg.go.dev/github.com/xmppo/go-xmpp

vietnguyen87 avatar Apr 16 '24 15:04 vietnguyen87

Then you should send something like this: https://xmpp.org/extensions/xep-0313.html#filter-time (ideally example 8 from that), with time from last message that you seen, and you should receive messages that were archived after that one.

prefiks avatar Apr 16 '24 15:04 prefiks

Thanks @prefiks, let's me try.

vietnguyen87 avatar Apr 16 '24 15:04 vietnguyen87

@vietnguyen87: What are your news since your latest comment?

Neustradamus avatar Jun 20 '24 13:06 Neustradamus

hi @Neustradamus , because i'm using ejabberd like a core chat system and golang service to communicate with client (Mobile app). So, i can handle something like: add created_at, get history chat... on my golang service.

vietnguyen87 avatar Jun 21 '24 03:06 vietnguyen87

I guess at this time, all the remaining questions were answered, or you have found an alternative solution.

badlop avatar Sep 09 '24 10:09 badlop