Support custom message tags
This provides a way for modules to register message tags and updates the core to send tags to clients if the relevant capabilities are enabled.
This commit is contained in:
1 parent
f9f9dec1ad
commit
6d0ec644d0
4 files changed
+53
-14
No files matched your search
+14
-12
@@ -558,23 +558,17 @@ bool CClient::PutClient(const CMessage& Message) {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: add the ability to set a list of tags to send
|
||||
MCString mssTags;
|
||||
|
||||
if (HasServerTime()) {
|
||||
CString sServerTime = Msg.GetTag("time");
|
||||
if (!sServerTime.empty()) {
|
||||
mssTags["time"] = sServerTime;
|
||||
} else {
|
||||
mssTags["time"] = CUtils::FormatServerTime(Msg.GetTime());
|
||||
for (const auto& it : Msg.GetTags()) {
|
||||
if (IsTagEnabled(it.first)) {
|
||||
mssTags[it.first] = it.second;
|
||||
}
|
||||
}
|
||||
|
||||
if (HasBatch()) {
|
||||
CString sBatch = Msg.GetTag("batch");
|
||||
if (!sBatch.empty()) {
|
||||
mssTags["batch"] = sBatch;
|
||||
}
|
||||
if (HasServerTime()) {
|
||||
// If the server didn't set the time tag, manually set it
|
||||
mssTags.emplace("time", CUtils::FormatServerTime(Msg.GetTime()));
|
||||
}
|
||||
|
||||
Msg.SetTags(mssTags);
|
||||
@@ -823,6 +817,14 @@ void CClient::ParseIdentifier(const CString& sAuthLine) {
|
||||
}
|
||||
}
|
||||
|
||||
void CClient::SetTagSupport(const CString& sTag, bool bState) {
|
||||
if (bState) {
|
||||
m_ssSupportedTags.insert(sTag);
|
||||
} else {
|
||||
m_ssSupportedTags.erase(sTag);
|
||||
}
|
||||
}
|
||||
|
||||
void CClient::NotifyServerDependentCaps(const SCString& ssCaps) {
|
||||
for (const CString& sCap : ssCaps) {
|
||||
const auto& it = m_mCoreCaps.find(sCap);
|
||||
|
||||
Reference in new issue
Block a user