1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

sv_ev_room_message: log in all cases if not our client

Forgot to check what happens if the length is <= 10.
This commit is contained in:
Michael Vetter 2019-10-18 11:59:39 +02:00
parent f7474cd72c
commit dfead6415f

View File

@ -285,6 +285,15 @@ sv_ev_room_history(ProfMessage *message)
} }
} }
static void _log_muc(ProfMessage *message)
{
if (message->enc == PROF_MSG_ENC_OMEMO) {
groupchat_log_omemo_msg_in(message->jid->barejid, message->jid->resourcepart, message->plain);
} else {
groupchat_log_msg_in(message->jid->barejid, message->jid->resourcepart, message->plain);
}
}
void void
sv_ev_room_message(ProfMessage *message) sv_ev_room_message(ProfMessage *message)
{ {
@ -302,23 +311,13 @@ sv_ev_room_message(ProfMessage *message)
// whether this client sent it. See connection_create_stanza_id() // whether this client sent it. See connection_create_stanza_id()
gsize tmp_len; gsize tmp_len;
char *tmp = (char*)g_base64_decode(message->id, &tmp_len); char *tmp = (char*)g_base64_decode(message->id, &tmp_len);
if (tmp_len > 10) { // log if not from this client. our client sents at least 10 for the identifier + random message bytes
// log if not from this client if ((tmp_len < 11) || (g_strcmp0(&tmp[10], connection_get_profanity_identifier()) != 0)) {
if (g_strcmp0(&tmp[10], connection_get_profanity_identifier()) != 0) { _log_muc(message);
if (message->enc == PROF_MSG_ENC_OMEMO) {
groupchat_log_omemo_msg_in(message->jid->barejid, message->jid->resourcepart, (char*)tmp);
} else {
groupchat_log_msg_in(message->jid->barejid, message->jid->resourcepart, message->plain);
}
}
} }
// messages from others // messages from others
} else { } else {
if (message->enc == PROF_MSG_ENC_OMEMO) { _log_muc(message);
groupchat_log_omemo_msg_in(message->jid->barejid, message->jid->resourcepart, message->plain);
} else {
groupchat_log_msg_in(message->jid->barejid, message->jid->resourcepart, message->plain);
}
} }
char *old_plain = message->plain; char *old_plain = message->plain;