Rework MODE/RPL_CHANMODEIS handling for trailing args (#1661)

Some servers may send a colon even if the last parameter doesn't need it, currently this leads to issues with permission/mode tracking, as the core doesn't handle the colon properly.

This fix replaces reconstructing the parameter string with just passing a vector of the relevant parameters to CChan::SetModes() and adds overrides for CChan::SetModes() and CChan::ModeChange() that accept the vector instead.

Clean up uses of old CModeMessage::GetModes()
This commit is contained in:
Aspen (linudaemon)
2019-08-08 15:54:49 -05:00
committed by Alexey Sokolov
parent 51e82fc7e8
commit 95369455fc
8 changed files with 165 additions and 19 deletions

View File

@@ -330,6 +330,23 @@ TEST_F(IRCSockTest, OnPartMessage) {
EXPECT_THAT(m_pTestModule->vChannels, ElementsAre(m_pTestChan));
}
TEST_F(IRCSockTest, StatusModes) {
m_pTestSock->ReadLine(":server 005 user PREFIX=(Yohv)!@%+ :are supported by this server");
EXPECT_TRUE(m_pTestSock->IsPermMode('Y'));
EXPECT_TRUE(m_pTestSock->IsPermMode('o'));
EXPECT_TRUE(m_pTestSock->IsPermMode('h'));
EXPECT_TRUE(m_pTestSock->IsPermMode('v'));
m_pTestChan->SetModes("+sp");
m_pTestChan->ModeChange("+Y :nick");
EXPECT_EQ(m_pTestChan->GetModeString(), "+ps");
const CNick& pNick = m_pTestChan->GetNicks().at("nick");
EXPECT_TRUE(pNick.HasPerm('!'));
EXPECT_FALSE(pNick.HasPerm('@'));
}
TEST_F(IRCSockTest, OnPingMessage) {
CMessage msg(":server PING :arg");
m_pTestSock->ReadLine(msg.ToString());