Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
vietnguyen87 opened this issue Apr 16, 2024 · 19 comments
Open

Comments

@vietnguyen87
Copy link

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.

@prefiks
Copy link
Member

prefiks commented Apr 16, 2024

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

@prefiks
Copy link
Member

prefiks commented Apr 16, 2024

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

@vietnguyen87
Copy link
Author

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

@prefiks
Copy link
Member

prefiks commented Apr 16, 2024

You can't any more.

@vietnguyen87
Copy link
Author

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

@prefiks
Copy link
Member

prefiks commented Apr 16, 2024

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

@vietnguyen87
Copy link
Author

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

@prefiks
Copy link
Member

prefiks commented Apr 16, 2024

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

@vietnguyen87
Copy link
Author

vietnguyen87 commented Apr 16, 2024

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....

@prefiks
Copy link
Member

prefiks commented Apr 16, 2024

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.

@vietnguyen87
Copy link
Author

vietnguyen87 commented Apr 16, 2024

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

Screenshot 2024-04-16 at 17 43 51

@prefiks
Copy link
Member

prefiks commented Apr 16, 2024

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?

@vietnguyen87
Copy link
Author

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?

@prefiks
Copy link
Member

prefiks commented Apr 16, 2024

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.

@vietnguyen87
Copy link
Author

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.

@prefiks
Copy link
Member

prefiks commented Apr 16, 2024

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?

@vietnguyen87
Copy link
Author

vietnguyen87 commented Apr 16, 2024

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

@prefiks
Copy link
Member

prefiks commented Apr 16, 2024

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.

@vietnguyen87
Copy link
Author

Thanks @prefiks, let's me try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants