Show admin log events for linked chats.

This commit is contained in:
John Preston 2019-05-24 14:05:52 +02:00
parent 0a86e732cd
commit 7fbec0dbca
2 changed files with 28 additions and 1 deletions

View File

@ -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}";

View File

@ -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);
});
}