diff options
| author | Nakidai Perumenei <nakidai@disroot.org> | 2026-12-02 23:47:07 +0300 |
|---|---|---|
| committer | Nakidai <nakidai@disroot.org> | 2026-01-30 15:34:30 +0300 |
| commit | 52d3575bf024caaeb4c4d517ad85c038331a67ea (patch) | |
| tree | 36f01cb619728e96f84c308132689f2ad6d3ae67 /handle.c | |
| parent | fc38c5fe075b46d2248bfec302481992dbe47188 (diff) | |
| download | libreircd-52d3575bf024caaeb4c4d517ad85c038331a67ea.tar.gz libreircd-52d3575bf024caaeb4c4d517ad85c038331a67ea.zip | |
Simplify join command
- Instead of checking users in the channel check user's channels - Ensure thing looks really dumb here, so remove it
Diffstat (limited to 'handle.c')
| -rw-r--r-- | handle.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/handle.c b/handle.c index 53e1c5b..776d839 100644 --- a/handle.c +++ b/handle.c @@ -26,7 +26,7 @@ static int join(struct Message *msg, struct Peer *peer) { - size_t i, j; + size_t i; /* TODO: support comma separated list of channels, keys */ ensure(peer->type, reply(peer, 451), 0); @@ -34,19 +34,16 @@ join(struct Message *msg, struct Peer *peer) ensure(peer->channels_c != lengthof(peer->channels), reply(peer, 405, msg->params[0]), 0) ensure(*msg->params[0] == '#', reply(peer, 403, msg->params[0]), 0); + for (i = 0; i < peer->channels_c; ++i) + ensure(strcmp(channels[i].name, msg->params[0]), (void)0, 0); + for (i = 0; i < channels_c; ++i) { if (strcmp(channels[i].name, msg->params[0])) continue; - for (j = 0; j < channels[i].users_c; ++j) - ensure( - strcmp(channels[i].users[j]->nick, peer->nick), - (void)0, - 0 - ); - - ensure(!channel_join(&channels[i], peer), reply(peer, 471), 0); + if (channel_join(&channels[i], peer)) + reply(peer, 471); return 0; } |