summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-06-17 12:17:44 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-06-17 12:17:44 +0300
commita228b0e44e9da5c5ef2f871f0cce63a4e8ae18ac (patch)
tree2a45928340873b2fbec55501ca4803ac36a45037
parent9aee9deca972b405a09033456ec2f270eea96cd3 (diff)
fixes #4466 (Telegram: при очистке истории канала нужно блокировать опции про удаление истории с сервера)
-rw-r--r--include/m_core.h2
-rw-r--r--include/m_protosvc.h7
-rw-r--r--libs/win32/mir_app.libbin298040 -> 298290 bytes
-rw-r--r--libs/win64/mir_app.libbin298056 -> 298292 bytes
-rw-r--r--plugins/NewStory/src/history_control.cpp2
-rw-r--r--protocols/Telegram/src/proto.cpp1
-rw-r--r--protocols/Telegram/src/proto.h2
-rw-r--r--protocols/Telegram/src/server.cpp12
-rw-r--r--src/mir_app/src/clui.cpp2
-rw-r--r--src/mir_app/src/mir_app.def1
-rw-r--r--src/mir_app/src/mir_app64.def1
-rw-r--r--src/mir_app/src/proto_utils.cpp11
-rw-r--r--src/mir_app/src/srmm_main.cpp2
13 files changed, 38 insertions, 5 deletions
diff --git a/include/m_core.h b/include/m_core.h
index c3e3df35a6..71fad47b41 100644
--- a/include/m_core.h
+++ b/include/m_core.h
@@ -319,6 +319,8 @@ MIR_CORE_DLL(int) mir_vsnwprintf(_Pre_notnull_ _Always_(_Post_z_) wchar_t *bu
struct PROTO_INTERFACE;
+MIR_APP_DLL(bool) Proto_CanDeleteHistory(const char *szModule, MCONTACT hContact);
+
MIR_APP_DLL(INT_PTR) ProtoBroadcastAck(const char *szModule, MCONTACT hContact, int type, int result, HANDLE hProcess, LPARAM lParam = 0);
MIR_APP_DLL(void) ProtoBroadcastAsync(const char *szModule, MCONTACT hContact, int type, int result, HANDLE hProcess, LPARAM lParam = 0);
diff --git a/include/m_protosvc.h b/include/m_protosvc.h
index 7f33cf5e2b..40537d2209 100644
--- a/include/m_protosvc.h
+++ b/include/m_protosvc.h
@@ -588,6 +588,13 @@ struct PROTOFILERESUME
#define PS_EMPTY_SRV_HISTORY "/EmptyServerHistory"
///////////////////////////////////////////////////////////////////////////////
+// Checks that server history for a contact can be removed
+// wParam = hContact
+// lParam = 0
+
+#define PS_CAN_EMPTY_HISTORY "/CanEmptyHistory"
+
+///////////////////////////////////////////////////////////////////////////////
// SENDING SERVICES
// these should be called with ProtoChainSend()
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib
index 24ebf7eb34..8dcb2afbc1 100644
--- a/libs/win32/mir_app.lib
+++ b/libs/win32/mir_app.lib
Binary files differ
diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib
index e8b7a9e6f0..71f65a06c5 100644
--- a/libs/win64/mir_app.lib
+++ b/libs/win64/mir_app.lib
Binary files differ
diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp
index 91dcfa58a3..6d2b156ecf 100644
--- a/plugins/NewStory/src/history_control.cpp
+++ b/plugins/NewStory/src/history_control.cpp
@@ -339,7 +339,7 @@ public:
chkForEveryone(this, IDC_BOTH)
{
if (char *szProto = Proto_GetBaseAccountName(hContact)) {
- bDelHistory = ProtoServiceExists(szProto, PS_EMPTY_SRV_HISTORY);
+ bDelHistory = Proto_CanDeleteHistory(szProto, hContact);
bForEveryone = (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_DELETEFORALL) != 0;
}
}
diff --git a/protocols/Telegram/src/proto.cpp b/protocols/Telegram/src/proto.cpp
index b1bc3b6c6f..f321758700 100644
--- a/protocols/Telegram/src/proto.cpp
+++ b/protocols/Telegram/src/proto.cpp
@@ -66,6 +66,7 @@ CTelegramProto::CTelegramProto(const char* protoName, const wchar_t* userName) :
CreateProtoService(PS_SETMYAVATAR, &CTelegramProto::SvcSetMyAvatar);
CreateProtoService(PS_MENU_LOADHISTORY, &CTelegramProto::SvcLoadServerHistory);
+ CreateProtoService(PS_CAN_EMPTY_HISTORY, &CTelegramProto::SvcCanEmptyHistory);
CreateProtoService(PS_EMPTY_SRV_HISTORY, &CTelegramProto::SvcEmptyServerHistory);
HookProtoEvent(ME_OPT_INITIALISE, &CTelegramProto::OnOptionsInit);
diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h
index 8466083bae..2216a3dc2b 100644
--- a/protocols/Telegram/src/proto.h
+++ b/protocols/Telegram/src/proto.h
@@ -419,6 +419,8 @@ public:
INT_PTR __cdecl SvcAddByPhone(WPARAM, LPARAM);
INT_PTR __cdecl SvcOfflineFile(WPARAM, LPARAM);
+
+ INT_PTR __cdecl SvcCanEmptyHistory(WPARAM, LPARAM);
INT_PTR __cdecl SvcLoadServerHistory(WPARAM, LPARAM);
INT_PTR __cdecl SvcEmptyServerHistory(WPARAM, LPARAM);
diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp
index 0568151f6d..cee7b9b1c3 100644
--- a/protocols/Telegram/src/server.cpp
+++ b/protocols/Telegram/src/server.cpp
@@ -498,10 +498,18 @@ INT_PTR CTelegramProto::SvcLoadServerHistory(WPARAM hContact, LPARAM)
///////////////////////////////////////////////////////////////////////////////
-INT_PTR CTelegramProto::SvcEmptyServerHistory(WPARAM hContact, LPARAM lParam)
+INT_PTR CTelegramProto::SvcCanEmptyHistory(WPARAM hContact, LPARAM)
{
- debugLogW(L"SvcEmptyServerHistory was called for cc=%d (%s)", (int)hContact, Clist_GetContactDisplayName(hContact));
+ if (auto *pUser = FindUser(GetId(hContact))) {
+ TG_SUPER_GROUP tmp(pUser->id, 0);
+ return m_arSuperGroups.find(&tmp) == nullptr;
+ }
+ return 0;
+}
+
+INT_PTR CTelegramProto::SvcEmptyServerHistory(WPARAM hContact, LPARAM lParam)
+{
if (auto *pUser = FindUser(GetId(hContact)))
if (pUser->chatId != -1)
SendQuery(new TD::deleteChatHistory(pUser->chatId, false, (lParam & CDF_FOR_EVERYONE) != 0));
diff --git a/src/mir_app/src/clui.cpp b/src/mir_app/src/clui.cpp
index e21acbd1af..fd692cf5aa 100644
--- a/src/mir_app/src/clui.cpp
+++ b/src/mir_app/src/clui.cpp
@@ -147,7 +147,7 @@ public:
{
szProto = Proto_GetBaseAccountName(hContact);
bHasServer = (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1) & PF1_SERVERCLIST) != 0;
- bHasHistory = ProtoServiceExists(szProto, PS_EMPTY_SRV_HISTORY);
+ bHasHistory = Proto_CanDeleteHistory(szProto, hContact);
bForEveryone = (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4) & PF4_DELETEFORALL) != 0;
chkDelHistory.OnChange = Callback(this, &CDeleteContactDlg::onChange_Server);
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index 9486812235..1547a72621 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -985,3 +985,4 @@ g_hevEventSetJson @1109 NONAME
??1MJsonWebSocket@@QAE@XZ @1121 NONAME
??_7MJsonWebSocket@@6B@ @1122 NONAME
?process@MJsonWebSocket@@EAEXPBEI@Z @1123 NONAME
+_Proto_CanDeleteHistory@8 @1124 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index a1a44174a0..07dd86a478 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -985,3 +985,4 @@ g_hevEventSetJson @1103 NONAME
??1MJsonWebSocket@@QEAA@XZ @1115 NONAME
??_7MJsonWebSocket@@6B@ @1116 NONAME
?process@MJsonWebSocket@@EEAAXPEBE_K@Z @1117 NONAME
+Proto_CanDeleteHistory @1118 NONAME
diff --git a/src/mir_app/src/proto_utils.cpp b/src/mir_app/src/proto_utils.cpp
index 78a0f33c69..10702e1473 100644
--- a/src/mir_app/src/proto_utils.cpp
+++ b/src/mir_app/src/proto_utils.cpp
@@ -105,6 +105,17 @@ MIR_APP_DLL(INT_PTR) ProtoBroadcastAck(const char *szModule, MCONTACT hContact,
/////////////////////////////////////////////////////////////////////////////////////////
+MIR_APP_DLL(bool) Proto_CanDeleteHistory(const char *szModule, MCONTACT hContact)
+{
+ if (!ProtoServiceExists(szModule, PS_EMPTY_SRV_HISTORY))
+ return false;
+
+ // CallProtoService can return CALLSERVICE_NOTFOUND, we don't care
+ return CallProtoService(szModule, PS_CAN_EMPTY_HISTORY, hContact) != 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
void PROTO_INTERFACE::setAllContactStatuses(int iStatus, bool bSkipChats)
{
for (auto &hContact : AccContacts()) {
diff --git a/src/mir_app/src/srmm_main.cpp b/src/mir_app/src/srmm_main.cpp
index a053a0a6e9..36c83e7ecc 100644
--- a/src/mir_app/src/srmm_main.cpp
+++ b/src/mir_app/src/srmm_main.cpp
@@ -46,7 +46,7 @@ public:
chkForEveryone(this, IDC_BOTH)
{
szProto = Proto_GetBaseAccountName(hContact);
- bDelHistory = ProtoServiceExists(szProto, PS_EMPTY_SRV_HISTORY);
+ bDelHistory = Proto_CanDeleteHistory(szProto, hContact);
bForEveryone = (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4) & PF4_DELETEFORALL) != 0;
}