summary refs log tree commit diff stats
path: root/src/common/proto-irc.c
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2021-05-24 02:53:28 +0100
committerGitHub <noreply@github.com>2021-05-23 20:53:28 -0500
commit37118a4d2b70c11a76c732346975c2745d3cc4c6 (patch)
treeb43cd4aa33f016b8826bdf420887cdb55551ee11 /src/common/proto-irc.c
parent6199635e7fbd220860e9b650b6d3fe63f60d4f80 (diff)
Implement support for the IRCv3 account-tag specification. (#2572)
Co-authored-by: Patrick <tingping@tingping.se>
Diffstat (limited to 'src/common/proto-irc.c')
-rw-r--r--src/common/proto-irc.c19
1 files changed, 19 insertions, 0 deletions
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,10 +1631,17 @@ 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)
 {
 	serv->p_inline = irc_inline;