diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e262f2a1..53d8bf0a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ SPDX-License-Identifier: GPL-3.0-or-later - core: fix buffer size in function util_parse_time, causing buffer overflow error in unit tests - irc: fix creation of irc.msgbuffer option without a server name +- irc: ignore self join if the channel is already joined ([#2291](https://github.com/weechat/weechat/issues/2291)) ## Version 4.8.1 (2025-12-01) diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index 539f347ad..9ac0882b8 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -1753,6 +1753,9 @@ IRC_PROTOCOL_CALLBACK(join) ptr_channel = irc_channel_search (ctxt->server, ctxt->params[0]); if (ptr_channel) { + /* ignore self join if the channel is already joined */ + if (ctxt->nick_is_me && ptr_channel->nicks) + return WEECHAT_RC_OK; ptr_channel->part = 0; } else diff --git a/tests/unit/plugins/irc/test-irc-protocol.cpp b/tests/unit/plugins/irc/test-irc-protocol.cpp index f1d08089c..810221437 100644 --- a/tests/unit/plugins/irc/test-irc-protocol.cpp +++ b/tests/unit/plugins/irc/test-irc-protocol.cpp @@ -2070,7 +2070,6 @@ TEST(IrcProtocolWithServer, join) LONGS_EQUAL(0, ptr_channel->has_quit_server); LONGS_EQUAL(0, ptr_channel->cycle); LONGS_EQUAL(0, ptr_channel->part); - LONGS_EQUAL(0, ptr_channel->part); STRCMP_EQUAL(NULL, ptr_channel->pv_remote_nick_color); POINTERS_EQUAL(NULL, ptr_channel->hook_autorejoin); @@ -2090,6 +2089,10 @@ TEST(IrcProtocolWithServer, join) CHECK(ptr_channel->buffer); + /* second self JOIN should be ignored if already joined */ + RECV(":alice!user@host JOIN #test "); + CHECK_NO_MSG; + RECV(":bob!user@host JOIN #test * : "); CHECK_CHAN("-->", "bob ( ) (user@host) has joined #test", "irc_join,irc_smart_filter,nick_bob,host_user@host,log4");