]> PatchyGit - patchyircd.git/commitdiff
make JOIN/PART idempotent
authorEgor <egor@patchysicp.xyz>
Fri, 6 May 2022 18:55:11 +0000 (21:55 +0300)
committerEgor <egor@patchysicp.xyz>
Fri, 6 May 2022 18:55:11 +0000 (21:55 +0300)
irc.c

diff --git a/irc.c b/irc.c
index eaa7426..c83f36a 100644 (file)
--- 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);