Merge pull request #1746 from NuclearW/account_tag

Add support for cap account-tag

Fix #607
This commit is contained in:
Alexey Sokolov
2020-08-08 09:58:41 +01:00
committed by GitHub
6 changed files with 31 additions and 0 deletions

View File

@@ -107,6 +107,7 @@ class CClient : public CIRCSocket {
m_bCapNotify(false),
m_bAwayNotify(false),
m_bAccountNotify(false),
m_bAccountTag(false),
m_bExtendedJoin(false),
m_bNamesx(false),
m_bUHNames(false),
@@ -148,6 +149,11 @@ class CClient : public CIRCSocket {
{true, [this](bool bVal) { m_bAwayNotify = bVal; }}},
{"account-notify",
{true, [this](bool bVal) { m_bAccountNotify = bVal; }}},
{"account-tag",
{true, [this](bool bVal) {
m_bAccountTag = bVal;
SetTagSupport("account", bVal);
}}},
{"extended-join",
{true, [this](bool bVal) { m_bExtendedJoin = bVal; }}},
}) {
@@ -178,6 +184,7 @@ class CClient : public CIRCSocket {
bool HasCapNotify() const { return m_bCapNotify; }
bool HasAwayNotify() const { return m_bAwayNotify; }
bool HasAccountNotify() const { return m_bAccountNotify; }
bool HasAccountTag() const { return m_bAccountTag; }
bool HasExtendedJoin() const { return m_bExtendedJoin; }
bool HasNamesx() const { return m_bNamesx; }
bool HasUHNames() const { return m_bUHNames; }
@@ -346,6 +353,7 @@ class CClient : public CIRCSocket {
bool m_bCapNotify;
bool m_bAwayNotify;
bool m_bAccountNotify;
bool m_bAccountTag;
bool m_bExtendedJoin;
bool m_bNamesx;
bool m_bUHNames;

View File

@@ -150,6 +150,7 @@ class CIRCSock : public CIRCSocket {
bool HasUHNames() const { return m_bUHNames; }
bool HasAwayNotify() const { return m_bAwayNotify; }
bool HasAccountNotify() const { return m_bAccountNotify; }
bool HasAccountTag() const { return m_bAccountTag; }
bool HasExtendedJoin() const { return m_bExtendedJoin; }
bool HasServerTime() const { return m_bServerTime; }
const std::set<char>& GetUserModes() const {
@@ -207,6 +208,7 @@ class CIRCSock : public CIRCSocket {
bool m_bUHNames;
bool m_bAwayNotify;
bool m_bAccountNotify;
bool m_bAccountTag;
bool m_bExtendedJoin;
bool m_bServerTime;
CString m_sPerms;

View File

@@ -854,6 +854,7 @@ void CClient::ClearServerDependentCaps() {
const auto& handler = std::get<1>(it->second);
handler(false);
}
m_ssAcceptedCaps.erase(sCap);
}
}

View File

@@ -67,6 +67,7 @@ CIRCSock::CIRCSock(CIRCNetwork* pNetwork)
m_bUHNames(false),
m_bAwayNotify(false),
m_bAccountNotify(false),
m_bAccountTag(false),
m_bExtendedJoin(false),
m_bServerTime(false),
m_sPerms("*!@%+"),
@@ -376,6 +377,7 @@ bool CIRCSock::OnCapabilityMessage(CMessage& Message) {
{"userhost-in-names", [this](bool bVal) { m_bUHNames = bVal; }},
{"away-notify", [this](bool bVal) { m_bAwayNotify = bVal; }},
{"account-notify", [this](bool bVal) { m_bAccountNotify = bVal; }},
{"account-tag", [this](bool bVal) { m_bAccountTag = bVal; }},
{"extended-join", [this](bool bVal) { m_bExtendedJoin = bVal; }},
{"server-time", [this](bool bVal) { m_bServerTime = bVal; }},
{"znc.in/server-time-iso",

View File

@@ -82,6 +82,23 @@ TEST_F(ClientTest, AccountNotify) {
EXPECT_THAT(m_pTestClient->vsLines, ElementsAre(msg.ToString()));
}
TEST_F(ClientTest, AccountTag) {
m_pTestSock->ReadLine(":server CAP * ACK :account-tag");
m_pTestClient->Reset();
CMessage msg(":nick!user@host PRIVMSG #channel :text");
CMessage extmsg("@account=account-name :nick!user@host PRIVMSG #channel :text");
EXPECT_FALSE(m_pTestClient->HasAccountTag());
m_pTestClient->PutClient(extmsg);
EXPECT_THAT(m_pTestClient->vsLines, ElementsAre(msg.ToString()));
m_pTestClient->SetAccountTag(true);
m_pTestClient->SetTagSupport("account", true);
EXPECT_TRUE(m_pTestClient->HasAccountTag());
m_pTestClient->PutClient(extmsg);
EXPECT_THAT(m_pTestClient->vsLines,
ElementsAre(msg.ToString(), extmsg.ToString()));
}
TEST_F(ClientTest, AwayNotify) {
CMessage msg(":nick!user@host AWAY :message");
EXPECT_FALSE(m_pTestClient->HasAwayNotify());

View File

@@ -36,6 +36,7 @@ class TestClient : public CClient {
}
void Reset() { vsLines.clear(); }
void SetAccountNotify(bool bEnabled) { m_bAccountNotify = bEnabled; }
void SetAccountTag(bool bEnabled) { m_bAccountTag = bEnabled; }
void SetAwayNotify(bool bEnabled) { m_bAwayNotify = bEnabled; }
void SetExtendedJoin(bool bEnabled) { m_bExtendedJoin = bEnabled; }
void SetNamesx(bool bEnabled) { m_bNamesx = bEnabled; }