|
Added
Link Here
|
| 1 |
The material part of https://github.com/ars3niy/tdlib-purple/pull/159 -- with the |
| 2 |
default switched to TRUE (to show self-destruct messages out of the box). |
| 3 |
|
| 4 |
-mi |
| 5 |
--- purple-info.h |
| 6 |
+++ purple-info.h |
| 7 |
@@ -40,6 +40,8 @@ namespace AccountOptions { |
| 8 |
constexpr gboolean EnableSecretChatsDefault = TRUE; |
| 9 |
constexpr const char *AnimatedStickers = "animated-stickers"; |
| 10 |
constexpr gboolean AnimatedStickersDefault = TRUE; |
| 11 |
+ constexpr const char *ShowSelfDestruct = "show-self-destruct"; |
| 12 |
+ constexpr gboolean ShowSelfDestructDefault = TRUE; |
| 13 |
constexpr const char *DownloadBehaviour = "download-behaviour"; |
| 14 |
constexpr const char *DownloadBehaviourHyperlink = "hyperlink"; |
| 15 |
constexpr const char *DownloadBehaviourStandard = "file-transfer"; |
| 16 |
--- receiving.cpp |
| 17 |
+++ receiving.cpp |
| 18 |
@@ -634,22 +634,37 @@ void showMessage(const td::td_api::chat &chat, IncomingMessage &fullMessage, |
| 19 |
messageInfo.repliedMessage = std::move(fullMessage.repliedMessage); |
| 20 |
|
| 21 |
if (message.ttl_ != 0) { |
| 22 |
- // TRANSLATOR: In-chat warning message |
| 23 |
- const char *text = _("Received self-destructing message, not displayed due to lack of support"); |
| 24 |
- std::string notice = makeNoticeWithSender(chat, messageInfo, text, account.purpleAccount); |
| 25 |
- showMessageText(account, chat, messageInfo, NULL, notice.c_str()); |
| 26 |
- return; |
| 27 |
+ if (purple_account_get_bool(account.purpleAccount, AccountOptions::ShowSelfDestruct, AccountOptions::ShowSelfDestructDefault)) { |
| 28 |
+ // TRANSLATOR: In-chat warning message |
| 29 |
+ const char *text = _("Received self-destructing message, displaying anyway"); |
| 30 |
+ std::string notice = makeNoticeWithSender(chat, messageInfo, text, account.purpleAccount); |
| 31 |
+ showMessageText(account, chat, messageInfo, NULL, notice.c_str()); |
| 32 |
+ } else { |
| 33 |
+ // TRANSLATOR: In-chat warning message |
| 34 |
+ const char *text = _("Received self-destructing message, not displayed due to lack of support"); |
| 35 |
+ std::string notice = makeNoticeWithSender(chat, messageInfo, text, account.purpleAccount); |
| 36 |
+ showMessageText(account, chat, messageInfo, NULL, notice.c_str()); |
| 37 |
+ return; |
| 38 |
+ } |
| 39 |
} |
| 40 |
|
| 41 |
FileInfo fileInfo; |
| 42 |
getFileFromMessage(fullMessage, fileInfo); |
| 43 |
if (fileInfo.secret) { |
| 44 |
- // TRANSLATOR: In-chat warning message |
| 45 |
- std::string notice = formatMessage("Ignoring secret file ({})", fileInfo.description); |
| 46 |
- notice = makeNoticeWithSender(chat, messageInfo, notice.c_str(), account.purpleAccount); |
| 47 |
- showMessageText(account, chat, messageInfo, !fileInfo.caption.empty() ? fileInfo.caption.c_str() : nullptr, |
| 48 |
- notice.c_str()); |
| 49 |
- return; |
| 50 |
+ if (purple_account_get_bool(account.purpleAccount, AccountOptions::ShowSelfDestruct, AccountOptions::ShowSelfDestructDefault)) { |
| 51 |
+ // TRANSLATOR: In-chat warning message |
| 52 |
+ std::string notice = formatMessage("Received secret file {}, displaying anyway", fileInfo.description); |
| 53 |
+ notice = makeNoticeWithSender(chat, messageInfo, notice.c_str(), account.purpleAccount); |
| 54 |
+ showMessageText(account, chat, messageInfo, !fileInfo.caption.empty() ? fileInfo.caption.c_str() : nullptr, |
| 55 |
+ notice.c_str()); |
| 56 |
+ } else { |
| 57 |
+ // TRANSLATOR: In-chat warning message |
| 58 |
+ std::string notice = formatMessage("Ignoring secret file ({})", fileInfo.description); |
| 59 |
+ notice = makeNoticeWithSender(chat, messageInfo, notice.c_str(), account.purpleAccount); |
| 60 |
+ showMessageText(account, chat, messageInfo, !fileInfo.caption.empty() ? fileInfo.caption.c_str() : nullptr, |
| 61 |
+ notice.c_str()); |
| 62 |
+ return; |
| 63 |
+ } |
| 64 |
} |
| 65 |
|
| 66 |
switch (message.content_->get_id()) { |
| 67 |
--- tdlib-purple.cpp |
| 68 |
+++ tdlib-purple.cpp |
| 69 |
@@ -1020,6 +1020,11 @@ static void tgprpl_init (PurplePlugin *plugin) |
| 70 |
prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, opt); |
| 71 |
#endif |
| 72 |
|
| 73 |
+ // TRANSLATOR: Account settings, key (boolean) |
| 74 |
+ opt = purple_account_option_bool_new(_("Show self-destructing messages anyway"), AccountOptions::ShowSelfDestruct, |
| 75 |
+ AccountOptions::ShowSelfDestructDefault); |
| 76 |
+ prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, opt); |
| 77 |
+ |
| 78 |
if (canDisableReadReceipts()) { |
| 79 |
opt = purple_account_option_bool_new ("Send read receipts", |
| 80 |
AccountOptions::ReadReceipts, |