summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Telegram/src/mt_proto.h1
-rw-r--r--protocols/Telegram/src/server.cpp33
2 files changed, 34 insertions, 0 deletions
diff --git a/protocols/Telegram/src/mt_proto.h b/protocols/Telegram/src/mt_proto.h
index 75f6869ad5..f3232592ce 100644
--- a/protocols/Telegram/src/mt_proto.h
+++ b/protocols/Telegram/src/mt_proto.h
@@ -116,6 +116,7 @@ class CMTProto : public PROTO<CMTProto>
void ProcessAuth(TD::updateAuthorizationState *pObj);
void ProcessChat(TD::updateNewChat *pObj);
+ void ProcessChatPosition(TD::updateChatPosition *pObj);
void ProcessGroups(TD::updateChatFilters *pObj);
void ProcessMessage(TD::updateNewMessage *pObj);
void ProcessStatus(TD::updateUserStatus *pObj);
diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp
index 9c1cf79d45..91ebc98fd0 100644
--- a/protocols/Telegram/src/server.cpp
+++ b/protocols/Telegram/src/server.cpp
@@ -105,6 +105,10 @@ void CMTProto::ProcessResponse(td::ClientManager::Response response)
ProcessGroups((TD::updateChatFilters *)response.object.get());
break;
+ case TD::updateChatPosition::ID:
+ ProcessChatPosition((TD::updateChatPosition *)response.object.get());
+ break;
+
case TD::updateNewChat::ID:
ProcessChat((TD::updateNewChat *)response.object.get());
break;
@@ -191,6 +195,35 @@ void CMTProto::ProcessChat(TD::updateNewChat *pObj)
setUString(pUser->hContact, "Nick", pChat->title_.c_str());
}
+void CMTProto::ProcessChatPosition(TD::updateChatPosition *pObj)
+{
+ if (pObj->position_->get_id() != TD::chatPosition::ID) {
+ debugLogA("Unsupport position");
+ return;
+ }
+
+ auto *pUser = FindUser(pObj->chat_id_);
+ if (pUser == nullptr) {
+ debugLogA("Unknown chat, skipping");
+ return;
+ }
+
+ auto *pPos = (TD::chatPosition *)pObj->position_.get();
+ if (pPos->list_) {
+ auto *pList = (TD::chatListFilter*)pPos->list_.get();
+
+ CMStringA szSetting(FORMAT, "ChatFilter%d", pList->chat_filter_id_);
+ CMStringW wszGroup(getMStringW(szSetting));
+ if (!wszGroup.IsEmpty()) {
+ ptrW pwszExistingGroup(Clist_GetGroup(pUser->hContact));
+ if (!pwszExistingGroup || !mir_wstrcmp(pwszExistingGroup, m_wszDefaultGroup)) {
+ CMStringW wszNewGroup(FORMAT, L"%s\\%s", (wchar_t *)m_wszDefaultGroup, wszGroup.c_str());
+ Clist_SetGroup(pUser->hContact, wszNewGroup);
+ }
+ }
+ }
+}
+
void CMTProto::ProcessGroups(TD::updateChatFilters *pObj)
{
for (auto &grp : pObj->chat_filters_) {