From f30c2991e34e2cf9bee03d755984435504fac091 Mon Sep 17 00:00:00 2001 From: Egor Date: Fri, 6 May 2022 21:55:11 +0300 Subject: [PATCH] make JOIN/PART idempotent --- irc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/irc.c b/irc.c index eaa7426..c83f36a 100644 --- a/irc.c +++ b/irc.c @@ -706,6 +706,8 @@ void channel_join(struct client_data *client, const char *channel, const char *c if (trie_set(&chan->o, client->key, client, NULL) == -1) abort(); } else { + if (trie_get(&chan->members, client->key)) + return; // TODO: check key // TODO: check limit // TODO: check ban @@ -728,6 +730,8 @@ void channel_join(struct client_data *client, const char *channel, const char *c } void channel_part(struct client_data *client, struct channel *chan, const char *reason) { + if (!trie_get(&chan->members, client->key)) + return; if (reason) { msg_part(client, chan, *reason ? reason : NULL); sendbuf_chan(chan); -- 2.56.0