summaryrefslogtreecommitdiff
path: root/protocols/Telegram/src/server.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2022-12-13 16:49:01 +0300
committerGeorge Hazan <ghazan@miranda.im>2022-12-13 16:49:01 +0300
commit1113b5c3a26280a3c2a330361579c84f533be468 (patch)
tree9553410ab27a4a12366b1fd316243be6abf8f632 /protocols/Telegram/src/server.cpp
parent1f446d528d3a9f517d4b4cf16aa139f17589cbb9 (diff)
Telegram: custom folders processing
Diffstat (limited to 'protocols/Telegram/src/server.cpp')
-rw-r--r--protocols/Telegram/src/server.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp
index 1905b4ae70..a852c1ac93 100644
--- a/protocols/Telegram/src/server.cpp
+++ b/protocols/Telegram/src/server.cpp
@@ -165,6 +165,32 @@ void CMTProto::OnUpdateAuth(td::ClientManager::Response &response)
///////////////////////////////////////////////////////////////////////////////
+void CMTProto::ProcessGroups(td::td_api::updateChatFilters *pObj)
+{
+ for (auto &grp : pObj->chat_filters_) {
+ if (grp->icon_name_ != "Custom")
+ continue;
+
+ CMStringA szSetting("ChatFilter%d", grp->id_);
+ CMStringW wszOldValue(getMStringW(szSetting));
+ Utf2T wszNewValue(grp->title_.c_str());
+ if (wszOldValue.IsEmpty()) {
+ Clist_GroupCreate(0, wszNewValue);
+ setWString(szSetting, wszNewValue);
+ }
+ else if (wszOldValue != wszNewValue) {
+ MGROUP oldGroup = Clist_GroupExists(wszNewValue);
+ if (!oldGroup)
+ Clist_GroupCreate(0, wszNewValue);
+ else
+ Clist_GroupRename(oldGroup, wszNewValue);
+ setWString(szSetting, wszNewValue);
+ }
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
void CMTProto::ProcessResponse(td::ClientManager::Response response)
{
if (!response.object)
@@ -185,6 +211,10 @@ void CMTProto::ProcessResponse(td::ClientManager::Response response)
case td::td_api::updateAuthorizationState::ID:
ProcessAuth((td::td_api::updateAuthorizationState *)response.object.get());
break;
+
+ case td::td_api::updateChatFilters::ID:
+ ProcessGroups((td::td_api::updateChatFilters *)response.object.get());
+ break;
}
}