diff options
author | George Hazan <george.hazan@gmail.com> | 2024-11-14 17:24:43 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-11-14 17:24:43 +0300 |
commit | efc8291dafe68435480bb5dd378cf26ee62d042f (patch) | |
tree | e8242a4090dd360c0fae964759237c93017966c5 /protocols | |
parent | e76a4df48aa890a0e466c10f8bf6c40438ffb92a (diff) |
fixes #4641 (Telegram: удаление с сервера чужих сообщений групчата, если пользователь Миранды не модератор/владелец)
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Telegram/src/proto.cpp | 21 | ||||
-rw-r--r-- | protocols/Telegram/src/proto.h | 2 | ||||
-rw-r--r-- | protocols/Telegram/src/server.cpp | 10 |
3 files changed, 19 insertions, 14 deletions
diff --git a/protocols/Telegram/src/proto.cpp b/protocols/Telegram/src/proto.cpp index 73834415b8..a61d72b6ba 100644 --- a/protocols/Telegram/src/proto.cpp +++ b/protocols/Telegram/src/proto.cpp @@ -349,21 +349,12 @@ int CTelegramProto::AuthRequest(MCONTACT hContact, const wchar_t *) INT_PTR CTelegramProto::GetCaps(int type, MCONTACT hContact) { - uint32_t ret; - switch (type) { case PFLAGNUM_1: return PF1_IM | PF1_FILE | PF1_CHAT | PF1_SEARCHBYNAME | PF1_ADDSEARCHRES | PF1_MODEMSGRECV | PF1_SERVERCLIST; case PFLAGNUM_2: return PF2_ONLINE | PF2_SHORTAWAY | PF2_LONGAWAY; - - case PFLAGNUM_4: - ret = PF4_NOCUSTOMAUTH | PF4_FORCEAUTH | PF4_OFFLINEFILES | PF4_NOAUTHDENYREASON | PF4_SUPPORTTYPING | PF4_AVATARS - | PF4_SERVERMSGID | PF4_REPLY | PF4_GROUPCHATFILES | PF4_IMSENDOFFLINE | PF4_SERVERFORMATTING; - if (GetId(hContact) != m_iOwnId) - ret |= PF4_DELETEFORALL; - return ret; case PFLAGNUM_5: return PF2_SHORTAWAY | PF2_LONGAWAY; @@ -371,9 +362,17 @@ INT_PTR CTelegramProto::GetCaps(int type, MCONTACT hContact) case PFLAG_UNIQUEIDTEXT: return (INT_PTR)L"ID"; - default: - return 0; + case PFLAGNUM_4: + uint32_t ret = PF4_NOCUSTOMAUTH | PF4_FORCEAUTH | PF4_OFFLINEFILES | PF4_NOAUTHDENYREASON | PF4_SUPPORTTYPING | PF4_AVATARS + | PF4_SERVERMSGID | PF4_REPLY | PF4_GROUPCHATFILES | PF4_IMSENDOFFLINE | PF4_SERVERFORMATTING; + + if (GetId(hContact) != m_iOwnId) + ret |= PF4_DELETEFORALL; + + return ret; } + + return 0; } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h index dec95199dc..69737ba35c 100644 --- a/protocols/Telegram/src/proto.h +++ b/protocols/Telegram/src/proto.h @@ -102,7 +102,7 @@ struct TG_USER : public MZeroedObject int64_t id, chatId = -1; MCONTACT hContact; int folderId = -1, nHistoryChunks; - bool isGroupChat, isChannel, isBot, isForum, bLoadMembers, bStartChat, bInited; + bool isGroupChat, isChannel, isBot, isForum, bLoadMembers, bStartChat, bInited, bDelOwn = true, bDelAll = true; CMStringA szAvatarHash; CMStringW wszNick, wszFirstName, wszLastName; time_t m_timer1 = 0, m_timer2 = 0; diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp index 9303509442..0f97275314 100644 --- a/protocols/Telegram/src/server.cpp +++ b/protocols/Telegram/src/server.cpp @@ -520,12 +520,16 @@ INT_PTR CTelegramProto::SvcLoadServerHistory(WPARAM hContact, LPARAM) ///////////////////////////////////////////////////////////////////////////////
-INT_PTR CTelegramProto::SvcCanEmptyHistory(WPARAM hContact, LPARAM)
+INT_PTR CTelegramProto::SvcCanEmptyHistory(WPARAM hContact, LPARAM bIncoming)
{
if (auto *pUser = FindUser(GetId(hContact))) {
TG_SUPER_GROUP tmp(pUser->id, 0);
if (auto *pGroup = m_arSuperGroups.find(&tmp))
- return !pGroup->group->is_channel_;
+ if (pGroup->group->is_channel_)
+ return 0;
+
+ if (!pUser->bDelOwn || (bIncoming && !pUser->bDelAll))
+ return 0;
return 1;
}
@@ -586,6 +590,8 @@ void CTelegramProto::ProcessChat(TD::updateNewChat *pObj) pUser->chatId = pChat->id_;
pUser->isChannel = isChannel;
+ pUser->bDelAll = pChat->can_be_deleted_for_all_users_;
+ pUser->bDelOwn = pChat->can_be_deleted_only_for_self_;
MCONTACT hContact = (pUser->id == m_iOwnId) ? 0 : pUser->hContact;
|