From 37118a4d2b70c11a76c732346975c2745d3cc4c6 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Mon, 24 May 2021 02:53:28 +0100 Subject: Implement support for the IRCv3 account-tag specification. (#2572) Co-authored-by: Patrick --- src/common/proto-irc.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/common/proto-irc.c') diff --git a/src/common/proto-irc.c b/src/common/proto-irc.c index 57eda88a..cfe76361 100644 --- a/src/common/proto-irc.c +++ b/src/common/proto-irc.c @@ -1010,6 +1010,7 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[], const message_tags_data *tags_data) { server *serv = sess->server; + char *account; char ip[128], nick[NICKLEN]; char *text, *ex; int len = strlen (type); @@ -1028,6 +1029,14 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[], ex[0] = '!'; } + + /** Update the account for this message's source. */ + if (serv->have_account_tag) + { + account = tags_data->account && *tags_data->account ? tags_data->account : "*"; + inbound_account (serv, nick, account, tags_data); + } + if (len == 4) { guint32 t; @@ -1522,6 +1531,9 @@ handle_message_tags (server *serv, const char *tags_str, *value = '\0'; value++; + if (serv->have_account_tag && !strcmp (key, "account")) + tags_data->account = g_strdup (value); + if (serv->have_server_time && !strcmp (key, "time")) handle_message_tag_time (value, tags_data); } @@ -1619,9 +1631,16 @@ irc_inline (server *serv, char *buf, int len) } xit: + message_tags_data_free (&tags_data); g_free (pdibuf); } +void +message_tags_data_free (message_tags_data *tags_data) +{ + g_clear_pointer (&tags_data->account, g_free); +} + void proto_fill_her_up (server *serv) { -- cgit 1.4.1