0
votes

Is it possible to get the timestamp of the message inside muc_filter_message hook ? I need to notify the muc messages, the notification payload must include the timestamp of the messages.

muc_filter_message(#message{from = From, body = Body} = Pkt,
           #state{config = Config, jid = RoomJID} = MUCState,
           FromNick) ->

    ?INFO_MSG("~p.", [From#jid.lserver]),

    PostUrl = gen_mod:get_module_opt(From#jid.lserver, ?MODULE, post_url, fun(S) -> iolist_to_binary(S) end, list_to_binary("")),

Is there a field that I can extract from Pkt which indicates the timestamp ?

In the client side, I got this frame where archived -> id is matching with the timestamp stored in the archive table of the ejabberd database

enter image description here

2

2 Answers

0
votes

What timestamp? A groupchat message, as described in https://xmpp.org/extensions/xep-0045.html does not contain any element or attribute about the timestamp. So, Pkt does not contain any time information.

0
votes

XMPP messages (including MUC) are not timestamped when they are delivered in real time. All timestamps you see in the client application and in logs are simply taken from the local clock when a message is received - this is why the chat log and your local application tend to show different timestamps.

In your use case, I think this means you should just generate your timestamp from the current time on the server.