Check for correct delay tag for muc timestamps

https://github.com/profanity-im/profanity/issues/1190 had another issue:
Sometimes servers send multiple </delay> and we just checked the first
one we got and only used it if the 'from' attribute was fitting.
However it could be that we actually wanted the second </delay> element
and there the 'from' would have been right.

So we need to loop through them until we get the one with the fitting
'from'.

Fix https://github.com/profanity-im/profanity/issues/1190
This commit is contained in:
Michael Vetter
2019-11-12 14:47:57 +01:00
parent ccb4d919b1
commit 61f66966dd
3 changed files with 42 additions and 19 deletions

View File

@@ -831,16 +831,17 @@ _handle_groupchat(xmpp_stanza_t *const stanza)
}
// determine if the notifications happened whilst offline
gchar *from;
message->timestamp = stanza_get_delay_from(stanza, &from);
// checking the domainpart is a workaround for some prosody versions (gh#1190)
if (message->timestamp && (g_strcmp0(jid->barejid, from) == 0
|| g_strcmp0(jid->domainpart, from) == 0)) {
message->timestamp = stanza_get_delay_from(stanza, jid->barejid);
if (message->timestamp == NULL) {
// checking the domainpart is a workaround for some prosody versions (gh#1190)
message->timestamp = stanza_get_delay_from(stanza, jid->domainpart);
}
if (message->timestamp) {
sv_ev_room_history(message);
} else {
sv_ev_room_message(message);
}
g_free(from);
out:
message_free(message);