muc: save oldest timestamp
So far we saved the timestamp which also had the `from`.
But we need this only to find out whether it's MUC history.
For displaying we should use the oldest delay timestamp.
Also in
61f66966dd (diff-4926fd4577a336bd3eb240f8104a5c5bL837)
a error was introduced.
Before we saved the timestamp in all cases. And only if timestamp AND
from was given we went into MUC history case.
Normal timestamp saving was not done anymore only if it also had a from
attribute.
Regards https://github.com/profanity-im/profanity/issues/1254
This commit is contained in:
@@ -1244,7 +1244,7 @@ _stanza_get_delay_timestamp_xep0091(xmpp_stanza_t *const x_stanza)
|
||||
GDateTime*
|
||||
stanza_get_delay_from(xmpp_stanza_t *const stanza, gchar *from)
|
||||
{
|
||||
xmpp_stanza_t *delay;
|
||||
xmpp_stanza_t *delay = NULL;
|
||||
|
||||
// first check for XEP-0203 delayed delivery
|
||||
if (from) {
|
||||
@@ -1272,6 +1272,35 @@ stanza_get_delay_from(xmpp_stanza_t *const stanza, gchar *from)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GDateTime*
|
||||
stanza_get_oldest_delay(xmpp_stanza_t *const stanza)
|
||||
{
|
||||
xmpp_stanza_t *child;
|
||||
const char *child_name;
|
||||
GDateTime* oldest;
|
||||
|
||||
for (child = xmpp_stanza_get_children(stanza); child; child = xmpp_stanza_get_next(child)) {
|
||||
|
||||
child_name = xmpp_stanza_get_name(child);
|
||||
|
||||
if (child_name && strcmp(child_name, STANZA_NAME_DELAY) == 0) {
|
||||
GDateTime *tmp = _stanza_get_delay_timestamp_xep0203(stanza);
|
||||
|
||||
if (!oldest || g_date_time_compare(oldest, tmp) == 1)
|
||||
oldest = tmp;
|
||||
}
|
||||
|
||||
if (child_name && strcmp(child_name, STANZA_NAME_X) == 0) {
|
||||
GDateTime *tmp = _stanza_get_delay_timestamp_xep0091(stanza);
|
||||
|
||||
if (!oldest || g_date_time_compare(oldest, tmp) == 1)
|
||||
oldest = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
return oldest;
|
||||
}
|
||||
|
||||
char*
|
||||
stanza_get_status(xmpp_stanza_t *stanza, char *def)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user