From 7d48adaf2496b1c22bf359fd6585c51271a21b4a Mon Sep 17 00:00:00 2001 From: Tony Olagbaiye Date: Sat, 17 Jul 2021 17:36:53 +0100 Subject: [PATCH] fix pm notifs --- channel.c | 2 +- connection.c | 18 +++++------------- input.c | 4 ++-- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/channel.c b/channel.c index 7a8a2a6..90c1af8 100644 --- a/channel.c +++ b/channel.c @@ -782,7 +782,7 @@ void channel__send_message(struct t_account *account, struct t_channel *channel, xmpp_stanza_release(message); if (channel->type != CHANNEL_TYPE_MUC) weechat_printf_date_tags(channel->buffer, 0, - "xmpp_message,message,notify_none,self_msg,log1", + "xmpp_message,message,private,notify_none,self_msg,log1", "%s\t%s", user__as_prefix_raw(account, account_jid(account)), body); diff --git a/connection.c b/connection.c index 6c24c90..eab0cc3 100644 --- a/connection.c +++ b/connection.c @@ -188,7 +188,6 @@ int connection__message_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void * if (from == NULL) return 1; from_bare = xmpp_jid_bare(account->context, from); - from = xmpp_jid_resource(account->context, from); channel = channel__search(account, from_bare); if (!channel) return 1; @@ -206,19 +205,10 @@ int connection__message_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void * sent, "forwarded", "urn:xmpp:forward:0"); received = xmpp_stanza_get_child_by_name_and_ns( stanza, "received", "urn:xmpp:carbons:2"); - if (sent && forwarded != NULL) - { - xmpp_stanza_t *message = xmpp_stanza_get_children(forwarded); - //from = xmpp_stanza_get_from(stanza); - //to = xmpp_stanza_get_to(stanza); - //xmpp_stanza_set_from(stanza, to); - //xmpp_stanza_set_to(stanza, from); - return connection__message_handler(conn, message, userdata); - } if (received) forwarded = xmpp_stanza_get_child_by_name_and_ns( received, "forwarded", "urn:xmpp:forward:0"); - if (received && forwarded != NULL) + if ((sent || received) && forwarded != NULL) { xmpp_stanza_t *message = xmpp_stanza_get_children(forwarded); return connection__message_handler(conn, message, userdata); @@ -401,10 +391,10 @@ int connection__message_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void * weechat_string_dyn_concat(dyn_tags, id, -1); } - if (strcmp(to, channel->id) == 0) + if (channel->type == CHANNEL_TYPE_PM) weechat_string_dyn_concat(dyn_tags, ",private", -1); if (weechat_string_match(intext, "/me *", 0)) - weechat_string_dyn_concat(dyn_tags, ",action", -1); + weechat_string_dyn_concat(dyn_tags, ",xmpp_action", -1); if (replace) { weechat_string_dyn_concat(dyn_tags, ",edit", -1); @@ -414,6 +404,8 @@ int connection__message_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void * if (date != 0) weechat_string_dyn_concat(dyn_tags, ",notify_none", -1); + else if (channel->type == CHANNEL_TYPE_PM) + weechat_string_dyn_concat(dyn_tags, ",notify_private", -1); else weechat_string_dyn_concat(dyn_tags, ",log1", -1); diff --git a/input.c b/input.c index e454ede..323a493 100644 --- a/input.c +++ b/input.c @@ -46,8 +46,8 @@ int input__data(struct t_gui_buffer *buffer, const char *text) } int input__data_cb(const void *pointer, void *data, - struct t_gui_buffer *buffer, - const char *text) + struct t_gui_buffer *buffer, + const char *text) { (void) pointer; (void) data;