From bf57a1506f1e5fb63600bd9d19b1f15509be8db6 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 30 Jun 2017 13:35:35 +0300 Subject: [PATCH] Fix assertion violation in the admin events log. Add support for a log entry about group/channel photo being removed. --- Telegram/Resources/langs/lang.strings | 2 ++ .../history/history_admin_log_item.cpp | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 20fbbb29bc..f28c9e6ca2 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -1346,6 +1346,8 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org "lng_admin_log_previous_link" = "Previous link"; "lng_admin_log_changed_photo_group" = "{from} changed group photo"; "lng_admin_log_changed_photo_channel" = "{from} changed channel photo"; +"lng_admin_log_removed_photo_group" = "{from} removed group photo"; +"lng_admin_log_removed_photo_channel" = "{from} removed channel photo"; "lng_admin_log_invites_enabled" = "{from} enabled group invites"; "lng_admin_log_invites_disabled" = "{from} disabled group invites"; "lng_admin_log_signatures_enabled" = "{from} enabled signatures"; diff --git a/Telegram/SourceFiles/history/history_admin_log_item.cpp b/Telegram/SourceFiles/history/history_admin_log_item.cpp index 66154d9663..a6d49deae5 100644 --- a/Telegram/SourceFiles/history/history_admin_log_item.cpp +++ b/Telegram/SourceFiles/history/history_admin_log_item.cpp @@ -307,11 +307,18 @@ void GenerateItems(gsl::not_null history, LocalIdManager &idManager, c }; auto createChangePhoto = [&](const MTPDchannelAdminLogEventActionChangePhoto &action) { - t_assert(action.vnew_photo.type() == mtpc_chatPhoto); - auto photo = GenerateChatPhoto(channel->bareId(), id, date, action.vnew_photo.c_chatPhoto()); - - auto text = (channel->isMegagroup() ? lng_admin_log_changed_photo_group : lng_admin_log_changed_photo_channel)(lt_from, fromLinkText); - addSimpleServiceMessage(text, photo); + switch (action.vnew_photo.type()) { + case mtpc_chatPhoto: { + auto photo = GenerateChatPhoto(channel->bareId(), id, date, action.vnew_photo.c_chatPhoto()); + auto text = (channel->isMegagroup() ? lng_admin_log_changed_photo_group : lng_admin_log_changed_photo_channel)(lt_from, fromLinkText); + addSimpleServiceMessage(text, photo); + } break; + case mtpc_chatPhotoEmpty: { + auto text = (channel->isMegagroup() ? lng_admin_log_removed_photo_group : lng_admin_log_removed_photo_channel)(lt_from, fromLinkText); + addSimpleServiceMessage(text); + } break; + default: Unexpected("ChatPhoto type in createChangePhoto()"); + } }; auto createToggleInvites = [&](const MTPDchannelAdminLogEventActionToggleInvites &action) {