diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2024-02-16 20:58:31 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2024-02-16 20:58:31 +0100 |
commit | 90c87e755377ea4b9ec7044916efe7d9cb0e1e41 (patch) | |
tree | b3b79141c348a6e7d7b1d959db5de46e041630a2 | |
parent | 162bcb26223daffb5e231adef47044a2aff628eb (diff) | |
download | weechat-90c87e755377ea4b9ec7044916efe7d9cb0e1e41.zip |
irc: add missing tags on self action messages when capability echo-message is enabled (closes #2074)
-rw-r--r-- | ChangeLog.adoc | 1 | ||||
-rw-r--r-- | src/plugins/irc/irc-command.c | 6 | ||||
-rw-r--r-- | src/plugins/irc/irc-input.c | 3 | ||||
-rw-r--r-- | src/plugins/irc/irc-input.h | 2 | ||||
-rw-r--r-- | src/plugins/irc/irc-protocol.c | 2 | ||||
-rw-r--r-- | tests/unit/plugins/irc/test-irc-protocol.cpp | 122 |
6 files changed, 90 insertions, 46 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 48d51a99c..e25a0725e 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -27,6 +27,7 @@ New features:: Bug fixes:: * core: remove trailing directory separators in home directories (issue #2070) + * irc: add missing tags on self action messages when capability echo-message is enabled (issue #2074) * irc: don't strip monospace color code 0x11 from incoming messages (issue #2073) * irc: fix random date displayed when a received message contains tags but no "time" (issue #2064) * scripts: fix crash on script unload when a hook is created in a buffer close callback (issue #2067) diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c index 52531047a..5a4747fcc 100644 --- a/src/plugins/irc/irc-command.c +++ b/src/plugins/irc/irc-command.c @@ -389,6 +389,7 @@ irc_command_me_channel_message (struct t_irc_server *server, server, 0, /* date */ 0, /* date_usec */ + NULL, /* tags */ channel_name, NULL, /* address */ "privmsg", @@ -1976,6 +1977,7 @@ IRC_COMMAND_CALLBACK(ctcp) ptr_server, 0, /* date */ 0, /* date_usec */ + NULL, /* tags */ ctcp_target, NULL, /* address */ "privmsg", @@ -3844,6 +3846,7 @@ IRC_COMMAND_CALLBACK(msg) ptr_server, 0, /* date */ 0, /* date_usec */ + NULL, /* tags */ ptr_channel->name, NULL, /* address */ "privmsg", @@ -3868,6 +3871,7 @@ IRC_COMMAND_CALLBACK(msg) ptr_server, 0, /* date */ 0, /* date_usec */ + NULL, /* tags */ targets[i], NULL, /* address */ "privmsg", @@ -4070,6 +4074,7 @@ IRC_COMMAND_CALLBACK(notice) ptr_server, 0, /* date */ 0, /* date_usec */ + NULL, /* tags */ argv[arg_target], NULL, /* address */ "notice", @@ -4601,6 +4606,7 @@ IRC_COMMAND_CALLBACK(query) ptr_server, 0, /* date */ 0, /* date_usec */ + NULL, /* tags */ ptr_channel->name, NULL, /* address */ "privmsg", diff --git a/src/plugins/irc/irc-input.c b/src/plugins/irc/irc-input.c index 299d9f7c3..789b88fb7 100644 --- a/src/plugins/irc/irc-input.c +++ b/src/plugins/irc/irc-input.c @@ -65,6 +65,7 @@ void irc_input_user_message_display (struct t_irc_server *server, time_t date, int date_usec, + struct t_hashtable *tags, const char *target, const char *address, const char *command, @@ -88,6 +89,7 @@ irc_input_user_message_display (struct t_irc_server *server, ctxt.server = server; ctxt.date = date; ctxt.date_usec = date_usec; + ctxt.tags = tags; ctxt.address = (char *)address; ctxt.command = (char *)command; @@ -325,6 +327,7 @@ irc_input_send_user_message (struct t_gui_buffer *buffer, int flags, ptr_server, 0, /* date */ 0, /* date_usec */ + NULL, /* tags */ ptr_channel->name, NULL, /* address */ "privmsg", diff --git a/src/plugins/irc/irc-input.h b/src/plugins/irc/irc-input.h index 1a947343b..f38a3681a 100644 --- a/src/plugins/irc/irc-input.h +++ b/src/plugins/irc/irc-input.h @@ -22,11 +22,13 @@ #include <time.h> +struct t_hashtable; struct t_gui_buffer; extern void irc_input_user_message_display (struct t_irc_server *server, time_t date, int date_usec, + struct t_hashtable *tags, const char *target, const char *address, const char *command, diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index cde4c4d6a..32e5a91b8 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -3056,6 +3056,7 @@ irc_protocol_privmsg_display_ctcp_send (struct t_irc_protocol_ctxt *ctxt, ctxt->server, ctxt->date, ctxt->date_usec, + ctxt->tags, target, ctxt->address, "privmsg", @@ -3347,6 +3348,7 @@ IRC_PROTOCOL_CALLBACK(privmsg) ctxt->server, ctxt->date, ctxt->date_usec, + ctxt->tags, remote_nick, ctxt->address, "privmsg", diff --git a/tests/unit/plugins/irc/test-irc-protocol.cpp b/tests/unit/plugins/irc/test-irc-protocol.cpp index cfec8b399..2f857dac4 100644 --- a/tests/unit/plugins/irc/test-irc-protocol.cpp +++ b/tests/unit/plugins/irc/test-irc-protocol.cpp @@ -2886,7 +2886,7 @@ TEST(IrcProtocolWithServer, privmsg) "irc_privmsg,irc_tag_tag1=value1,irc_tag_tag2=value2," "notify_private,prefix_nick_248,nick_bob,host_user@host,log1"); - /* message with tags + time as timestamp to channel/user */ + /* message with tags + time as timestamp to channel/user */ RECV("@tag1=value1;tag2=value2;time=1703500149 :bob!user@host PRIVMSG #test " ":this is the message "); CHECK_CHAN_DATE_VALUE( @@ -3088,86 +3088,109 @@ TEST(IrcProtocolWithServer, privmsg) "), name: file.txt, 3 bytes (protocol: dcc)"); /* valid CTCP to channel */ - RECV(":bob!user@host PRIVMSG #test :\01TEST\01"); - RECV(":bob!user@host PRIVMSG #test :\01ACTION\01"); + RECV("@time=2023-12-25T10:29:09.456789Z " + ":bob!user@host PRIVMSG #test :\01TEST\01"); + RECV("@time=2023-12-25T10:29:09.456789Z " + ":bob!user@host PRIVMSG #test :\01ACTION\01"); CHECK_CHAN(" *", "bob", - "irc_privmsg,irc_action,notify_message,nick_bob," - "host_user@host,log1"); - RECV(":bob!user@host PRIVMSG #test :\01ACTION is testing with \02bold\02\01"); + "irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z," + "irc_action,notify_message,nick_bob,host_user@host,log1"); + RECV("@time=2023-12-25T10:29:09.456789Z " + ":bob!user@host PRIVMSG #test :\01ACTION is testing with \02bold\02\01"); CHECK_CHAN(" *", "bob is testing with bold", - "irc_privmsg,irc_action,notify_message,nick_bob," - "host_user@host,log1"); + "irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z," + "irc_action,notify_message,nick_bob,host_user@host,log1"); RECV(":bob!user@host PRIVMSG #test :\01VERSION\01"); RECV(":bob!user@host PRIVMSG #test :\01DCC SEND file.txt 1 2 3\01"); /* valid CTCP to ops of channel */ - RECV(":bob!user@host PRIVMSG @#test :\01ACTION\01"); + RECV("@time=2023-12-25T10:29:09.456789Z " + ":bob!user@host PRIVMSG @#test :\01ACTION\01"); CHECK_CHAN("--", "Action -> @#test: bob", - "irc_privmsg,irc_action,notify_message,nick_bob," - "host_user@host,log1"); - RECV(":bob!user@host PRIVMSG @#test :\01ACTION is testing\01"); + "irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z," + "irc_action,notify_message,nick_bob,host_user@host,log1"); + RECV("@time=2023-12-25T10:29:09.456789Z " + ":bob!user@host PRIVMSG @#test :\01ACTION is testing\01"); CHECK_CHAN("--", "Action -> @#test: bob is testing", - "irc_privmsg,irc_action,notify_message,nick_bob," - "host_user@host,log1"); + "irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z," + "irc_action,notify_message,nick_bob,host_user@host,log1"); /* * valid CTCP to channel from self nick * (case of bouncer or if echo-message capability is enabled) */ - RECV(":alice!user@host PRIVMSG #test :\01VERSION\01"); + RECV("@time=2023-12-25T10:29:09.456789Z " + ":alice!user@host PRIVMSG #test :\01VERSION\01"); CHECK_CHAN("--", "CTCP query to #test: VERSION", - "irc_privmsg,irc_ctcp,self_msg,notify_none,no_highlight," - "nick_alice,host_user@host,log1"); - RECV(":alice!user@host PRIVMSG #test :\01ACTION\01"); + "irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z," + "irc_ctcp,self_msg,notify_none,no_highlight,nick_alice," + "host_user@host,log1"); + RECV("@time=2023-12-25T10:29:09.456789Z " + ":alice!user@host PRIVMSG #test :\01ACTION\01"); CHECK_CHAN(" *", "alice", - "irc_privmsg,irc_action,self_msg,notify_none,no_highlight," - "nick_alice,host_user@host,log1"); - RECV(":alice!user@host PRIVMSG #test :\01ACTION is testing with \02bold\02\01"); + "irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z," + "irc_action,self_msg,notify_none,no_highlight,nick_alice," + "host_user@host,log1"); + RECV("@time=2023-12-25T10:29:09.456789Z " + ":alice!user@host PRIVMSG #test :\01ACTION is testing with \02bold\02\01"); CHECK_CHAN(" *", "alice is testing with bold", - "irc_privmsg,irc_action,self_msg,notify_none,no_highlight," - "nick_alice,host_user@host,log1"); + "irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z," + "irc_action,self_msg,notify_none,no_highlight,nick_alice," + "host_user@host,log1"); /* * valid CTCP to ops of channel from self nick * (case of bouncer or if echo-message capability is enabled) */ - RECV(":alice!user@host PRIVMSG @#test :\01ACTION\01"); + RECV("@time=2023-12-25T10:29:09.456789Z " + ":alice!user@host PRIVMSG @#test :\01ACTION\01"); CHECK_CHAN("--", "Action -> @#test: alice", - "irc_privmsg,irc_action,self_msg,notify_none,no_highlight," - "nick_alice,host_user@host,log1"); - RECV(":alice!user@host PRIVMSG @#test :\01ACTION is testing\01"); + "irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z," + "irc_action,self_msg,notify_none,no_highlight,nick_alice," + "host_user@host,log1"); + RECV("@time=2023-12-25T10:29:09.456789Z " + ":alice!user@host PRIVMSG @#test :\01ACTION is testing\01"); CHECK_CHAN("--", "Action -> @#test: alice is testing", - "irc_privmsg,irc_action,self_msg,notify_none,no_highlight," - "nick_alice,host_user@host,log1"); + "irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z," + "irc_action,self_msg,notify_none,no_highlight,nick_alice," + "host_user@host,log1"); /* valid CTCP to user */ - RECV(":bob!user@host PRIVMSG alice :\01TEST\01"); + RECV("@time=2023-12-25T10:29:09.456789Z " + ":bob!user@host PRIVMSG alice :\01TEST\01"); CHECK_SENT(NULL); - RECV(":bob!user@host PRIVMSG alice :\01ACTION\01"); + RECV("@time=2023-12-25T10:29:09.456789Z " + ":bob!user@host PRIVMSG alice :\01ACTION\01"); CHECK_SENT(NULL); - RECV(":bob!user@host PRIVMSG alice :\01ACTION is testing\01"); + RECV("@time=2023-12-25T10:29:09.456789Z " + ":bob!user@host PRIVMSG alice :\01ACTION is testing\01"); CHECK_SENT(NULL); - RECV(":bob!user@host PRIVMSG alice :\01VERSION\01"); + RECV("@time=2023-12-25T10:29:09.456789Z " + ":bob!user@host PRIVMSG alice :\01VERSION\01"); CHECK_SRV("--", "CTCP requested by bob: VERSION", - "irc_privmsg,irc_ctcp,nick_bob,host_user@host,log1"); + "irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z," + "irc_ctcp,nick_bob,host_user@host,log1"); info = irc_ctcp_eval_reply (ptr_server, irc_ctcp_get_reply (ptr_server, "VERSION")); snprintf (message, sizeof (message), "CTCP reply to bob: VERSION %s", info); CHECK_SRV("--", message, - "irc_privmsg,irc_ctcp,irc_ctcp_reply,self_msg,notify_none," - "no_highlight,nick_alice,log1"); + "irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z," + "irc_ctcp,irc_ctcp_reply,self_msg,notify_none,no_highlight," + "nick_alice,log1"); snprintf (message, sizeof (message), "NOTICE bob :\01VERSION %s\01", info); CHECK_SENT(message); free (info); - RECV(":bob!user@host PRIVMSG alice :\01SOURCE\01"); + RECV("@time=2023-12-25T10:29:09.456789Z " + ":bob!user@host PRIVMSG alice :\01SOURCE\01"); info = hook_info_get (NULL, "weechat_site_download", ""); snprintf (message, sizeof (message), "NOTICE bob :\01SOURCE %s\01", info); CHECK_SENT(message); free (info); - RECV(":bob!user@host PRIVMSG alice :\01DCC SEND file.txt 1 2 3\01"); + RECV("@time=2023-12-25T10:29:09.456789Z " + ":bob!user@host PRIVMSG alice :\01DCC SEND file.txt 1 2 3\01"); CHECK_CORE("", "xfer: incoming file from bob (0.0.0.1, irc." IRC_FAKE_SERVER "), name: file.txt, 3 bytes (protocol: dcc)"); @@ -3177,31 +3200,38 @@ TEST(IrcProtocolWithServer, privmsg) * valid CTCP to channel from self nick * (case of bouncer or if echo-message capability is enabled) */ - RECV(":alice!user@host PRIVMSG alice :\01CLIENTINFO\01"); + RECV("@time=2023-12-25T10:29:09.456789Z " + ":alice!user@host PRIVMSG alice :\01CLIENTINFO\01"); if (i == 0) { CHECK_SRV("--", "CTCP requested by alice: CLIENTINFO", - "irc_privmsg,irc_ctcp,nick_alice,host_user@host,log1"); + "irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z," + "irc_ctcp,nick_alice,host_user@host,log1"); CHECK_SRV("--", "CTCP reply to alice: CLIENTINFO ACTION CLIENTINFO " "DCC PING SOURCE TIME VERSION", - "irc_privmsg,irc_ctcp,irc_ctcp_reply,self_msg,notify_none," + "irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z," + "irc_ctcp,irc_ctcp_reply,self_msg,notify_none," "no_highlight,nick_alice,host_user@host,log1"); } else { CHECK_SRV("--", "CTCP query to alice: CLIENTINFO", - "irc_privmsg,irc_ctcp,self_msg,notify_none,no_highlight," - "nick_alice,host_user@host,log1"); + "irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z," + "irc_ctcp,self_msg,notify_none,no_highlight,nick_alice," + "host_user@host,log1"); /* * with echo-message capability, when the same message is received * for the second time, the request and reply are displayed */ - RECV(":alice!user@host PRIVMSG alice :\01CLIENTINFO\01"); + RECV("@time=2023-12-25T10:29:09.456789Z " + ":alice!user@host PRIVMSG alice :\01CLIENTINFO\01"); CHECK_SRV("--", "CTCP requested by alice: CLIENTINFO", - "irc_privmsg,irc_ctcp,nick_alice,host_user@host,log1"); + "irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z," + "irc_ctcp,nick_alice,host_user@host,log1"); CHECK_SRV("--", "CTCP reply to alice: CLIENTINFO ACTION CLIENTINFO " "DCC PING SOURCE TIME VERSION", - "irc_privmsg,irc_ctcp,irc_ctcp_reply,self_msg,notify_none," + "irc_privmsg,irc_tag_time=2023-12-25T10:29:09.456789Z," + "irc_ctcp,irc_ctcp_reply,self_msg,notify_none," "no_highlight,nick_alice,host_user@host,log1"); } |