From 7fbec0dbca813de38f740930689bd94ebfcfb1fd Mon Sep 17 00:00:00 2001 From: John Preston <johnprestonmail@gmail.com> Date: Fri, 24 May 2019 14:05:52 +0200 Subject: [PATCH] Show admin log events for linked chats. --- Telegram/Resources/langs/lang.strings | 4 +++ .../admin_log/history_admin_log_item.cpp | 25 ++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 5c00d081d..269be8d8c 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -1707,6 +1707,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_admin_log_changed_stickers_group" = "{from} changed the group's {sticker_set}"; "lng_admin_log_changed_stickers_set" = "sticker set"; "lng_admin_log_removed_stickers_group" = "{from} removed the group's sticker set"; +"lng_admin_log_changed_linked_chat" = "{from} changed the discussion group to «{chat}»"; +"lng_admin_log_removed_linked_chat" = "{from} removed the discussion group"; +"lng_admin_log_changed_linked_channel" = "{from} changed the linked channel to «{chat}»"; +"lng_admin_log_removed_linked_channel" = "{from} removed the linked channel"; "lng_admin_log_user_with_username" = "{name} ({mention})"; "lng_admin_log_restricted_forever" = "indefinitely"; "lng_admin_log_restricted_until" = "until {date}"; diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp index eea0d3652..0c43c0bd2 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp @@ -580,6 +580,29 @@ void GenerateItems( detachExistingItem)); }; + auto createChangeLinkedChat = [&](const MTPDchannelAdminLogEventActionChangeLinkedChat &action) { + const auto broadcast = channel->isBroadcast(); + const auto was = history->owner().channelLoaded(action.vprev_value.v); + const auto now = history->owner().channelLoaded(action.vnew_value.v); + if (!now) { + auto text = (broadcast ? lng_admin_log_removed_linked_chat : lng_admin_log_removed_linked_channel)(lt_from, fromLinkText); + addSimpleServiceMessage(text); + } else { + auto text = (broadcast ? lng_admin_log_changed_linked_chat : lng_admin_log_changed_linked_channel)( + lt_from, + fromLinkText, + lt_chat, + textcmdLink(2, now->name)); + auto chatLink = std::make_shared<LambdaClickHandler>([=] { + Ui::showPeerHistory(now, ShowAtUnreadMsgId); + }); + auto message = HistoryService::PreparedText{ text }; + message.links.push_back(fromLink); + message.links.push_back(chatLink); + addPart(history->owner().makeServiceMessage(history, idManager->next(), date, message, MTPDmessage::Flags(0), peerToUser(from->id))); + } + }; + action.match([&](const MTPDchannelAdminLogEventActionChangeTitle &data) { createChangeTitle(data); }, [&](const MTPDchannelAdminLogEventActionChangeAbout &data) { @@ -617,7 +640,7 @@ void GenerateItems( }, [&](const MTPDchannelAdminLogEventActionStopPoll &data) { createStopPoll(data); }, [&](const MTPDchannelAdminLogEventActionChangeLinkedChat &data) { - // #TODO discussion + createChangeLinkedChat(data); }); }