summaryrefslogtreecommitdiff
path: root/protocols/Telegram/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-10-19 19:46:32 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-10-19 19:46:32 +0300
commit83de2b9e7e2023835c452c127fed667df86e6d22 (patch)
treef3206a761411df3ab295d1a3e9abcdc6d08aed3e /protocols/Telegram/src
parent488510a94b352d817512aef7e12a07d564a20c62 (diff)
fixes #4750 (Telegram: add an option not to generate previews for links)
Diffstat (limited to 'protocols/Telegram/src')
-rw-r--r--protocols/Telegram/src/options.cpp6
-rw-r--r--protocols/Telegram/src/proto.cpp4
-rw-r--r--protocols/Telegram/src/proto.h2
-rw-r--r--protocols/Telegram/src/utils.cpp8
4 files changed, 8 insertions, 12 deletions
diff --git a/protocols/Telegram/src/options.cpp b/protocols/Telegram/src/options.cpp
index c89d8518e1..bb27acf95a 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, chkGenPreview;
+ CCtrlCheck chkHideChats, chkUsePopups, chkCompressFiles, chkIncludePreviews;
CCtrlCombo cmbCountry;
CCtrlEdit edtGroup, edtPhone, edtDeviceName;
ptrW m_wszOldGroup;
@@ -34,11 +34,11 @@ public:
cmbCountry(this, IDC_COUNTRY),
chkUsePopups(this, IDC_POPUPS),
chkHideChats(this, IDC_HIDECHATS),
- chkGenPreview(this, IDC_USE_PREVIEW),
edtPhone(this, IDC_PHONE),
edtGroup(this, IDC_DEFGROUP),
edtDeviceName(this, IDC_DEVICE_NAME),
chkCompressFiles(this, IDC_COMPRESS_FILES),
+ chkIncludePreviews(this, IDC_USE_PREVIEW),
m_wszOldGroup(mir_wstrdup(ppro->m_wszDefaultGroup))
{
CreateLink(edtPhone, ppro->m_szOwnPhone);
@@ -48,8 +48,8 @@ public:
if (bFullDlg) {
CreateLink(chkUsePopups, ppro->m_bUsePopups);
- CreateLink(chkGenPreview, ppro->m_bUrlPreview);
CreateLink(chkCompressFiles, ppro->m_bCompressFiles);
+ CreateLink(chkIncludePreviews, ppro->m_bIncludePreviews);
}
btnLogout.OnClick = Callback(this, &COptionsDlg::onClick_Logout);
diff --git a/protocols/Telegram/src/proto.cpp b/protocols/Telegram/src/proto.cpp
index 17c8e04cb7..403a40f686 100644
--- a/protocols/Telegram/src/proto.cpp
+++ b/protocols/Telegram/src/proto.cpp
@@ -55,9 +55,9 @@ CTelegramProto::CTelegramProto(const char* protoName, const wchar_t* userName) :
m_wszDeviceName(this, "DeviceName", L"Miranda NG"),
m_wszDefaultGroup(this, "DefaultGroup", L"Telegram"),
m_bUsePopups(this, "UsePopups", true),
- m_bUrlPreview(this, "UrlPreview", true),
m_bCompressFiles(this, "CompressFiles", true),
- m_bHideGroupchats(this, "HideChats", true)
+ m_bHideGroupchats(this, "HideChats", true),
+ m_bIncludePreviews(this, "IncludePreview", true)
{
m_iOwnId = GetId(0);
diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h
index 4d76651b48..a2bebd4b71 100644
--- a/protocols/Telegram/src/proto.h
+++ b/protocols/Telegram/src/proto.h
@@ -442,7 +442,7 @@ public:
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_bUrlPreview; // embrace URLs into [url] tags
+ 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<uint32_t> m_iStatus1;
diff --git a/protocols/Telegram/src/utils.cpp b/protocols/Telegram/src/utils.cpp
index 79fce40608..8cbed517a3 100644
--- a/protocols/Telegram/src/utils.cpp
+++ b/protocols/Telegram/src/utils.cpp
@@ -98,11 +98,6 @@ CMStringA CTelegramProto::GetFormattedText(TD::object_ptr<TD::formattedText> &pT
case TD::textEntityTypeUnderline::ID: iCode = 3; break;
case TD::textEntityTypeCode::ID: iCode = 5; break;
case TD::textEntityTypeBlockQuote::ID: iCode = 6; break;
- case TD::textEntityTypeUrl::ID:
- if (!m_bUrlPreview)
- continue;
- iCode = 4;
- break;
default:
continue;
}
@@ -772,7 +767,8 @@ CMStringA CTelegramProto::GetMessageText(TG_USER *pUser, const TD::message *pMsg
if (auto *pText = ((TD::messageText *)pBody)) {
ret = GetFormattedText(pText->text_);
- if (auto *pWeb = pText->link_preview_.get()) {
+ auto *pWeb = pText->link_preview_.get();
+ if (pWeb && m_bIncludePreviews) {
CMStringA szDescr;
if (!pWeb->site_name_.empty())