1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Merge pull request #1174 from weiss/check-muc-delay

Don't render (all) delayed messages as MUC history
This commit is contained in:
Michael Vetter 2019-08-21 08:11:27 +02:00 committed by GitHub
commit 75c13d4922
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 2 deletions

View File

@ -821,12 +821,14 @@ _handle_groupchat(xmpp_stanza_t *const stanza)
} }
// determine if the notifications happened whilst offline // determine if the notifications happened whilst offline
message->timestamp = stanza_get_delay(stanza); gchar *from;
if (message->timestamp) { message->timestamp = stanza_get_delay_from(stanza, &from);
if (message->timestamp && g_strcmp0(jid->barejid, from) == 0) {
sv_ev_room_history(message); sv_ev_room_history(message);
} else { } else {
sv_ev_room_message(message); sv_ev_room_message(message);
} }
g_free(from);
out: out:
message_free(message); message_free(message);

View File

@ -1173,6 +1173,12 @@ stanza_create_caps_sha1_from_query(xmpp_stanza_t *const query)
GDateTime* GDateTime*
stanza_get_delay(xmpp_stanza_t *const stanza) stanza_get_delay(xmpp_stanza_t *const stanza)
{
return stanza_get_delay_from(stanza, NULL);
}
GDateTime*
stanza_get_delay_from(xmpp_stanza_t *const stanza, gchar **from)
{ {
GTimeVal utc_stamp; GTimeVal utc_stamp;
// first check for XEP-0203 delayed delivery // first check for XEP-0203 delayed delivery
@ -1185,6 +1191,9 @@ stanza_get_delay(xmpp_stanza_t *const stanza)
GDateTime *utc_datetime = g_date_time_new_from_timeval_utc(&utc_stamp); GDateTime *utc_datetime = g_date_time_new_from_timeval_utc(&utc_stamp);
GDateTime *local_datetime = g_date_time_to_local(utc_datetime); GDateTime *local_datetime = g_date_time_to_local(utc_datetime);
g_date_time_unref(utc_datetime); g_date_time_unref(utc_datetime);
if (from) {
*from = g_strdup(xmpp_stanza_get_attribute(delay, STANZA_ATTR_FROM));
}
return local_datetime; return local_datetime;
} }
} }
@ -1201,11 +1210,17 @@ stanza_get_delay(xmpp_stanza_t *const stanza)
GDateTime *utc_datetime = g_date_time_new_from_timeval_utc(&utc_stamp); GDateTime *utc_datetime = g_date_time_new_from_timeval_utc(&utc_stamp);
GDateTime *local_datetime = g_date_time_to_local(utc_datetime); GDateTime *local_datetime = g_date_time_to_local(utc_datetime);
g_date_time_unref(utc_datetime); g_date_time_unref(utc_datetime);
if (from) {
*from = g_strdup(xmpp_stanza_get_attribute(x, STANZA_ATTR_FROM));
}
return local_datetime; return local_datetime;
} }
} }
} }
if (from) {
*from = NULL;
}
return NULL; return NULL;
} }

View File

@ -267,6 +267,7 @@ xmpp_stanza_t* stanza_create_mediated_invite(xmpp_ctx_t *ctx, const char *const
gboolean stanza_contains_chat_state(xmpp_stanza_t *stanza); gboolean stanza_contains_chat_state(xmpp_stanza_t *stanza);
GDateTime* stanza_get_delay(xmpp_stanza_t *const stanza); GDateTime* stanza_get_delay(xmpp_stanza_t *const stanza);
GDateTime* stanza_get_delay_from(xmpp_stanza_t *const stanza, gchar **from);
gboolean stanza_is_muc_presence(xmpp_stanza_t *const stanza); gboolean stanza_is_muc_presence(xmpp_stanza_t *const stanza);
gboolean stanza_is_muc_self_presence(xmpp_stanza_t *const stanza, gboolean stanza_is_muc_self_presence(xmpp_stanza_t *const stanza,