summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-10-19 20:06:12 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-10-19 20:06:12 +0300
commitb6926beda6415e0a53915cc2541c75daa768e05a (patch)
treeef9bb5002f968dddf10c0b0316c20131238722a7
parent83de2b9e7e2023835c452c127fed667df86e6d22 (diff)
Telegram: an option not to store channel messages
-rw-r--r--protocols/Telegram/res/resource.rc5
-rw-r--r--protocols/Telegram/src/options.cpp4
-rw-r--r--protocols/Telegram/src/proto.cpp3
-rw-r--r--protocols/Telegram/src/proto.h19
-rw-r--r--protocols/Telegram/src/resource.h1
-rw-r--r--protocols/Telegram/src/server.cpp51
6 files changed, 51 insertions, 32 deletions
diff --git a/protocols/Telegram/res/resource.rc b/protocols/Telegram/res/resource.rc
index 88de0a2305..cb6181fb51 100644
--- a/protocols/Telegram/res/resource.rc
+++ b/protocols/Telegram/res/resource.rc
@@ -97,7 +97,10 @@ BEGIN
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,83,294,10
CONTROL "Compress files on send",IDC_COMPRESS_FILES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,96,294,10
PUSHBUTTON "Log out",IDC_LOGOUT,212,168,86,14
- CONTROL "Include URL preview into message text",IDC_USE_PREVIEW,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,109,294,10
+ CONTROL "Include URL preview into message text",IDC_USE_PREVIEW,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,109,294,10
+ CONTROL "Store channel messages in memory only",IDC_RESIDENT_CHANNELS,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,122,294,10
END
IDD_OPTIONS_ADV DIALOGEX 0, 0, 310, 86
diff --git a/protocols/Telegram/src/options.cpp b/protocols/Telegram/src/options.cpp
index bb27acf95a..8b31ce3c1c 100644
--- a/protocols/Telegram/src/options.cpp
+++ b/protocols/Telegram/src/options.cpp
@@ -22,7 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
class COptionsDlg : public CTelegramDlgBase
{
CCtrlButton btnLogout;
- CCtrlCheck chkHideChats, chkUsePopups, chkCompressFiles, chkIncludePreviews;
+ CCtrlCheck chkHideChats, chkUsePopups, chkCompressFiles, chkIncludePreviews, chkResidentChannels;
CCtrlCombo cmbCountry;
CCtrlEdit edtGroup, edtPhone, edtDeviceName;
ptrW m_wszOldGroup;
@@ -39,6 +39,7 @@ public:
edtDeviceName(this, IDC_DEVICE_NAME),
chkCompressFiles(this, IDC_COMPRESS_FILES),
chkIncludePreviews(this, IDC_USE_PREVIEW),
+ chkResidentChannels(this, IDC_RESIDENT_CHANNELS),
m_wszOldGroup(mir_wstrdup(ppro->m_wszDefaultGroup))
{
CreateLink(edtPhone, ppro->m_szOwnPhone);
@@ -50,6 +51,7 @@ public:
CreateLink(chkUsePopups, ppro->m_bUsePopups);
CreateLink(chkCompressFiles, ppro->m_bCompressFiles);
CreateLink(chkIncludePreviews, ppro->m_bIncludePreviews);
+ CreateLink(chkResidentChannels, ppro->m_bResidentChannels);
}
btnLogout.OnClick = Callback(this, &COptionsDlg::onClick_Logout);
diff --git a/protocols/Telegram/src/proto.cpp b/protocols/Telegram/src/proto.cpp
index 403a40f686..ab8a4f10b2 100644
--- a/protocols/Telegram/src/proto.cpp
+++ b/protocols/Telegram/src/proto.cpp
@@ -57,7 +57,8 @@ CTelegramProto::CTelegramProto(const char* protoName, const wchar_t* userName) :
m_bUsePopups(this, "UsePopups", true),
m_bCompressFiles(this, "CompressFiles", true),
m_bHideGroupchats(this, "HideChats", true),
- m_bIncludePreviews(this, "IncludePreview", true)
+ m_bIncludePreviews(this, "IncludePreview", true),
+ m_bResidentChannels(this, "ResidentChannels", false)
{
m_iOwnId = GetId(0);
diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h
index a2bebd4b71..3b47eb22c0 100644
--- a/protocols/Telegram/src/proto.h
+++ b/protocols/Telegram/src/proto.h
@@ -436,17 +436,18 @@ public:
// Options ///////////////////////////////////////////////////////////////////////////
- CMOption<uint32_t> m_iCountry; // set this status to m_iStatus1 after this interval of secs
- CMOption<wchar_t*> m_szOwnPhone; // our own phone number
- CMOption<wchar_t*> m_wszDefaultGroup; // clist group to store contacts
- CMOption<wchar_t*> m_wszDeviceName; // how do you see this session in Device List
- CMOption<bool> m_bHideGroupchats; // do not open chat windows on creation
+ CMOption<uint32_t> m_iCountry; // set this status to m_iStatus1 after this interval of secs
+ CMOption<wchar_t*> m_szOwnPhone; // our own phone number
+ CMOption<wchar_t*> m_wszDefaultGroup; // clist group to store contacts
+ CMOption<wchar_t*> m_wszDeviceName; // how do you see this session in Device List
+ CMOption<bool> m_bHideGroupchats; // do not open chat windows on creation
CMOption<bool> m_bUsePopups;
- CMOption<bool> m_bIncludePreviews; // include URL previews into message text
- CMOption<bool> m_bCompressFiles; // embed pictures & videos into a message on send
- CMOption<uint32_t> m_iTimeDiff1; // set this status to m_iStatus1 after this interval of secs
+ CMOption<bool> m_bIncludePreviews; // include URL previews into message text
+ CMOption<bool> m_bResidentChannels; // don't store channel messages in a database
+ CMOption<bool> m_bCompressFiles; // embed pictures & videos into a message on send
+ CMOption<uint32_t> m_iTimeDiff1; // set this status to m_iStatus1 after this interval of secs
CMOption<uint32_t> m_iStatus1;
- CMOption<uint32_t> m_iTimeDiff2; // set this status to m_iStatus2 after this interval of secs
+ CMOption<uint32_t> m_iTimeDiff2; // set this status to m_iStatus2 after this interval of secs
CMOption<uint32_t> m_iStatus2;
// Processing Threads ////////////////////////////////////////////////////////////////
diff --git a/protocols/Telegram/src/resource.h b/protocols/Telegram/src/resource.h
index ba4fad485f..59a64c9a48 100644
--- a/protocols/Telegram/src/resource.h
+++ b/protocols/Telegram/src/resource.h
@@ -35,6 +35,7 @@
#define IDC_COMPRESS_FILES 1017
#define IDC_REACTIONS 1018
#define IDC_USE_PREVIEW 1018
+#define IDC_RESIDENT_CHANNELS 1019
#define IDC_SESSIONS 1023
#define IDC_SOFTWARE 1025
#define IDC_LOGOUT 1025
diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp
index 5c47412389..575287087f 100644
--- a/protocols/Telegram/src/server.cpp
+++ b/protocols/Telegram/src/server.cpp
@@ -927,28 +927,39 @@ void CTelegramProto::ProcessMessage(const TD::message *pMessage)
hContact = si->hContact;
}
- DB::EventInfo dbei(hOldEvent);
- dbei.szId = szMsgId;
- dbei.cbBlob = szText.GetLength();
- dbei.timestamp = pMessage->date_;
- if (pMessage->is_outgoing_)
- dbei.flags |= DBEF_SENT;
- if (!pUser->bInited)
- dbei.flags |= DBEF_READ;
- if (GetGcUserId(pUser, pMessage, szUserId))
- dbei.szUserId = szUserId;
- if (auto iReplyId = getReplyId(pMessage->reply_to_.get())) {
- szReplyId = msg2id(pMessage->chat_id_, iReplyId);
- dbei.szReplyId = szReplyId;
- }
-
- if (dbei) {
- replaceStr(dbei.pBlob, szText.Detach());
- db_event_edit(hOldEvent, &dbei, true);
+ if (m_bResidentChannels && pUser->isChannel && pUser->m_si) {
+ GCEVENT gce = { pUser->m_si, GC_EVENT_MESSAGE };
+ gce.dwFlags = GCEF_ADDTOLOG | GCEF_UTF8;
+ gce.pszText.a = szText;
+ gce.pszNick.a = szUserId;
+ gce.pszUID.a = szUserId;
+ gce.time = pMessage->date_;
+ Chat_Event(&gce);
}
else {
- dbei.pBlob = szText.GetBuffer();
- ProtoChainRecvMsg(hContact, dbei);
+ DB::EventInfo dbei(hOldEvent);
+ dbei.szId = szMsgId;
+ dbei.cbBlob = szText.GetLength();
+ dbei.timestamp = pMessage->date_;
+ if (pMessage->is_outgoing_)
+ dbei.flags |= DBEF_SENT;
+ if (!pUser->bInited)
+ dbei.flags |= DBEF_READ;
+ if (GetGcUserId(pUser, pMessage, szUserId))
+ dbei.szUserId = szUserId;
+ if (auto iReplyId = getReplyId(pMessage->reply_to_.get())) {
+ szReplyId = msg2id(pMessage->chat_id_, iReplyId);
+ dbei.szReplyId = szReplyId;
+ }
+
+ if (dbei) {
+ replaceStr(dbei.pBlob, szText.Detach());
+ db_event_edit(hOldEvent, &dbei, true);
+ }
+ else {
+ dbei.pBlob = szText.GetBuffer();
+ ProtoChainRecvMsg(hContact, dbei);
+ }
}
}