diff options
author | Michael Vetter <jubalh@iodoru.org> | 2020-04-11 23:56:01 +0200 |
---|---|---|
committer | Michael Vetter <jubalh@iodoru.org> | 2020-04-11 23:56:01 +0200 |
commit | dd566d8d561099bbfc81b2fab22318bbad0cf3da (patch) | |
tree | 2e32e9ff2a68d02dda146cf8897174553112d24b /src/xmpp | |
parent | 180ec2b474b39de0b22964adbfc5e13bc3d2c791 (diff) | |
download | profani-tty-dd566d8d561099bbfc81b2fab22318bbad0cf3da.tar.gz |
MAM: Correctly display incoming MAM chat message
Diffstat (limited to 'src/xmpp')
-rw-r--r-- | src/xmpp/message.c | 19 | ||||
-rw-r--r-- | src/xmpp/xmpp.h | 1 |
2 files changed, 13 insertions, 7 deletions
diff --git a/src/xmpp/message.c b/src/xmpp/message.c index 59970012..d8d12a74 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -84,7 +84,7 @@ static void _handle_muc_private_message(xmpp_stanza_t *const stanza); static void _handle_conference(xmpp_stanza_t *const stanza); static void _handle_captcha(xmpp_stanza_t *const stanza); static void _handle_receipt_received(xmpp_stanza_t *const stanza); -static void _handle_chat(xmpp_stanza_t *const stanza); +static void _handle_chat(xmpp_stanza_t *const stanza, gboolean is_mam); static gboolean _handle_mam(xmpp_stanza_t *const stanza); static void _send_message_stanza(xmpp_stanza_t *const stanza); @@ -166,7 +166,7 @@ _message_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *con } } - _handle_chat(stanza); + _handle_chat(stanza, FALSE); return 1; } @@ -1161,7 +1161,7 @@ out: } static void -_handle_chat(xmpp_stanza_t *const stanza) +_handle_chat(xmpp_stanza_t *const stanza, gboolean is_mam) { // ignore if type not chat or absent const char *type = xmpp_stanza_get_type(stanza); @@ -1206,10 +1206,15 @@ _handle_chat(xmpp_stanza_t *const stanza) // standard chat message, use jid without resource ProfMessage *message = message_init(); - // TODO: safe to_jid too. also need to have the same check like in carbons. in case this is MAM. - // or have a is_mam and handle later. - message->from_jid = jid; message->type = PROF_MSG_TYPE_CHAT; + message->from_jid = jid; + + const gchar *to_text = xmpp_stanza_get_to(stanza); + if (to_text) { + message->to_jid = jid_create(to_text); + } + + message->is_mam = is_mam; // message stanza id const char *id = xmpp_stanza_get_id(stanza); @@ -1296,7 +1301,7 @@ _handle_mam(xmpp_stanza_t *const stanza) } xmpp_stanza_t *message_stanza = xmpp_stanza_get_child_by_ns(forwarded, "jabber:client"); - _handle_chat(message_stanza); + _handle_chat(message_stanza, TRUE); return TRUE; } diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h index 3f384fb7..cb0004e3 100644 --- a/src/xmpp/xmpp.h +++ b/src/xmpp/xmpp.h @@ -155,6 +155,7 @@ typedef struct prof_message_t { GDateTime *timestamp; prof_enc_t enc; gboolean trusted; + gboolean is_mam; prof_msg_type_t type; } ProfMessage; |