diff --git a/Telegram/SourceFiles/ayu/ui/sections/edited/edited_log_item.cpp b/Telegram/SourceFiles/ayu/ui/sections/edited/edited_log_item.cpp index 4133c1b19..2c68a3fdb 100644 --- a/Telegram/SourceFiles/ayu/ui/sections/edited/edited_log_item.cpp +++ b/Telegram/SourceFiles/ayu/ui/sections/edited/edited_log_item.cpp @@ -39,162 +39,6 @@ namespace EditedLog namespace { -TextWithEntities PrepareText( - const QString &value, - const QString &emptyValue) -{ - auto result = TextWithEntities{value}; - if (result.text.isEmpty()) { - result.text = emptyValue; - if (!emptyValue.isEmpty()) { - result.entities.push_back({ - EntityType::Italic, - 0, - int(emptyValue.size())}); - } - } - else { - TextUtilities::ParseEntities( - result, - TextParseLinks - | TextParseMentions - | TextParseHashtags - | TextParseBotCommands); - } - return result; -} - -[[nodiscard]] TimeId ExtractSentDate(const MTPMessage &message) -{ - return message.match([](const MTPDmessageEmpty &) - { - return 0; - }, [](const MTPDmessageService &data) - { - return data.vdate().v; - }, [](const MTPDmessage &data) - { - return data.vdate().v; - }); -} - -[[nodiscard]] MsgId ExtractRealMsgId(const MTPMessage &message) -{ - return MsgId(message.match([](const MTPDmessageEmpty &) - { - return 0; - }, [](const MTPDmessageService &data) - { - return data.vid().v; - }, [](const MTPDmessage &data) - { - return data.vid().v; - })); -} - -MTPMessage PrepareLogMessage(const MTPMessage &message, TimeId newDate) -{ - return message.match([&](const MTPDmessageEmpty &data) - { - return MTP_messageEmpty( - data.vflags(), - data.vid(), - data.vpeer_id() ? *data.vpeer_id() : MTPPeer()); - }, [&](const MTPDmessageService &data) - { - const auto removeFlags = MTPDmessageService::Flag::f_out - | MTPDmessageService::Flag::f_post - | MTPDmessageService::Flag::f_reply_to - | MTPDmessageService::Flag::f_ttl_period; - return MTP_messageService( - MTP_flags(data.vflags().v & ~removeFlags), - data.vid(), - data.vfrom_id() ? *data.vfrom_id() : MTPPeer(), - data.vpeer_id(), - MTPMessageReplyHeader(), - MTP_int(newDate), - data.vaction(), - MTPint()); // ttl_period - }, [&](const MTPDmessage &data) - { - const auto removeFlags = MTPDmessage::Flag::f_out - | MTPDmessage::Flag::f_post - | MTPDmessage::Flag::f_reply_to - | MTPDmessage::Flag::f_replies - | MTPDmessage::Flag::f_edit_date - | MTPDmessage::Flag::f_grouped_id - | MTPDmessage::Flag::f_views - | MTPDmessage::Flag::f_forwards - //| MTPDmessage::Flag::f_reactions - | MTPDmessage::Flag::f_restriction_reason - | MTPDmessage::Flag::f_ttl_period; - return MTP_message( - MTP_flags(data.vflags().v & ~removeFlags), - data.vid(), - data.vfrom_id() ? *data.vfrom_id() : MTPPeer(), - data.vpeer_id(), - data.vfwd_from() ? *data.vfwd_from() : MTPMessageFwdHeader(), - MTP_long(data.vvia_bot_id().value_or_empty()), - MTPMessageReplyHeader(), - MTP_int(newDate), - data.vmessage(), - data.vmedia() ? *data.vmedia() : MTPMessageMedia(), - data.vreply_markup() ? *data.vreply_markup() : MTPReplyMarkup(), - (data.ventities() - ? *data.ventities() - : MTPVector()), - MTP_int(data.vviews().value_or_empty()), - MTP_int(data.vforwards().value_or_empty()), - MTPMessageReplies(), - MTPint(), // edit_date - MTP_string(), - MTP_long(0), // grouped_id - MTPMessageReactions(), - MTPVector(), - MTPint()); // ttl_period - }); -} - -bool MediaCanHaveCaption(const MTPMessage &message) -{ - if (message.type() != mtpc_message) { - return false; - } - const auto &data = message.c_message(); - const auto media = data.vmedia(); - const auto mediaType = media ? media->type() : mtpc_messageMediaEmpty; - return (mediaType == mtpc_messageMediaDocument) - || (mediaType == mtpc_messageMediaPhoto); -} - -uint64 MediaId(const MTPMessage &message) -{ - if (!MediaCanHaveCaption(message)) { - return 0; - } - const auto &media = message.c_message().vmedia(); - return media - ? v::match( - Data::GetFileReferences(*media).data.begin()->first, - [](const auto &d) - { return d.id; }) - : 0; -} - -TextWithEntities ExtractEditedText( - not_null session, - const MTPMessage &message) -{ - if (message.type() != mtpc_message) { - return TextWithEntities(); - } - const auto &data = message.c_message(); - return { - qs(data.vmessage()), - Api::EntitiesFromMTP(session, data.ventities().value_or_empty()) - }; -} - const auto CollectChanges = []( auto &phraseMap, auto plusFlags, @@ -860,1101 +704,6 @@ void GenerateItems( const auto text = QString::fromStdString(message.text); addSimpleTextMessage(Ui::Text::WithEntities(text)); -// -// const auto createChangeAbout = [&](const LogAbout &action) -// { -// const auto newValue = qs(action.vnew_value()); -// const auto oldValue = qs(action.vprev_value()); -// const auto text = (channel->isMegagroup() -// ? (newValue.isEmpty() -// ? tr::lng_admin_log_removed_description_group -// : tr::lng_admin_log_changed_description_group) -// : (newValue.isEmpty() -// ? tr::lng_admin_log_removed_description_channel -// : tr::lng_admin_log_changed_description_channel) -// )(tr::now, lt_from, fromLinkText, Ui::Text::WithEntities); -// addSimpleServiceMessage(text); -// -// const auto body = makeSimpleTextMessage( -// PrepareText(newValue, QString())); -// if (!oldValue.isEmpty()) { -// const auto oldDescription = PrepareText(oldValue, QString()); -// body->addLogEntryOriginal( -// id, -// tr::lng_admin_log_previous_description(tr::now), -// oldDescription); -// } -// addPart(body); -// }; -// -// const auto createChangeUsername = [&](const LogUsername &action) -// { -// const auto newValue = qs(action.vnew_value()); -// const auto oldValue = qs(action.vprev_value()); -// const auto text = (channel->isMegagroup() -// ? (newValue.isEmpty() -// ? tr::lng_admin_log_removed_link_group -// : tr::lng_admin_log_changed_link_group) -// : (newValue.isEmpty() -// ? tr::lng_admin_log_removed_link_channel -// : tr::lng_admin_log_changed_link_channel) -// )(tr::now, lt_from, fromLinkText, Ui::Text::WithEntities); -// addSimpleServiceMessage(text); -// -// const auto body = makeSimpleTextMessage(newValue.isEmpty() -// ? TextWithEntities() -// : PrepareText( -// history->session().createInternalLinkFull(newValue), -// QString())); -// if (!oldValue.isEmpty()) { -// const auto oldLink = PrepareText( -// history->session().createInternalLinkFull(oldValue), -// QString()); -// body->addLogEntryOriginal( -// id, -// tr::lng_admin_log_previous_link(tr::now), -// oldLink); -// } -// addPart(body); -// }; -// -// const auto createChangePhoto = [&](const LogPhoto &action) -// { -// action.vnew_photo().match([&](const MTPDphoto &data) -// { -// const auto photo = history->owner().processPhoto(data); -// const auto text = (channel->isMegagroup() -// ? tr::lng_admin_log_changed_photo_group -// : tr::lng_admin_log_changed_photo_channel)( -// tr::now, -// lt_from, -// fromLinkText, -// Ui::Text::WithEntities); -// addSimpleServiceMessage(text, MsgId(), photo); -// }, [&](const MTPDphotoEmpty &data) -// { -// const auto text = (channel->isMegagroup() -// ? tr::lng_admin_log_removed_photo_group -// : tr::lng_admin_log_removed_photo_channel)( -// tr::now, -// lt_from, -// fromLinkText, -// Ui::Text::WithEntities); -// addSimpleServiceMessage(text); -// }); -// }; -// -// const auto createToggleInvites = [&](const LogInvites &action) -// { -// const auto enabled = (action.vnew_value().type() == mtpc_boolTrue); -// const auto text = (enabled -// ? tr::lng_admin_log_invites_enabled -// : tr::lng_admin_log_invites_disabled)( -// tr::now, -// lt_from, -// fromLinkText, -// Ui::Text::WithEntities); -// addSimpleServiceMessage(text); -// }; -// -// const auto createToggleSignatures = [&](const LogSign &action) -// { -// const auto enabled = (action.vnew_value().type() == mtpc_boolTrue); -// const auto text = (enabled -// ? tr::lng_admin_log_signatures_enabled -// : tr::lng_admin_log_signatures_disabled)( -// tr::now, -// lt_from, -// fromLinkText, -// Ui::Text::WithEntities); -// addSimpleServiceMessage(text); -// }; -// -// const auto createUpdatePinned = [&](const LogPin &action) -// { -// action.vmessage().match([&](const MTPDmessage &data) -// { -// const auto pinned = data.is_pinned(); -// const auto realId = ExtractRealMsgId(action.vmessage()); -// const auto text = (pinned -// ? tr::lng_admin_log_pinned_message -// : tr::lng_admin_log_unpinned_message)( -// tr::now, -// lt_from, -// fromLinkText, -// Ui::Text::WithEntities); -// addSimpleServiceMessage(text, realId); -// -// const auto detachExistingItem = false; -// addPart( -// history->createItem( -// history->nextNonHistoryEntryId(), -// PrepareLogMessage(action.vmessage(), date), -// MessageFlag::AdminLogEntry, -// detachExistingItem), -// ExtractSentDate(action.vmessage()), -// realId); -// }, [&](const auto &) -// { -// const auto text = tr::lng_admin_log_unpinned_message( -// tr::now, -// lt_from, -// fromLinkText, -// Ui::Text::WithEntities); -// addSimpleServiceMessage(text); -// }); -// }; -// -// const auto createEditMessage = [&](const LogEdit &action) -// { -// const auto realId = ExtractRealMsgId(action.vnew_message()); -// const auto sentDate = ExtractSentDate(action.vnew_message()); -// const auto newValue = ExtractEditedText( -// session, -// action.vnew_message()); -// auto oldValue = ExtractEditedText( -// session, -// action.vprev_message()); -// -// const auto canHaveCaption = MediaCanHaveCaption( -// action.vnew_message()); -// const auto changedCaption = (newValue != oldValue); -// const auto changedMedia = MediaId(action.vnew_message()) -// != MediaId(action.vprev_message()); -// const auto removedCaption = !oldValue.text.isEmpty() -// && newValue.text.isEmpty(); -// const auto text = (!canHaveCaption -// ? tr::lng_admin_log_edited_message -// : (changedMedia && removedCaption) -// ? tr::lng_admin_log_edited_media_and_removed_caption -// : (changedMedia && changedCaption) -// ? tr::lng_admin_log_edited_media_and_caption -// : changedMedia -// ? tr::lng_admin_log_edited_media -// : removedCaption -// ? tr::lng_admin_log_removed_caption -// : changedCaption -// ? tr::lng_admin_log_edited_caption -// : tr::lng_admin_log_edited_message)( -// tr::now, -// lt_from, -// fromLinkText, -// Ui::Text::WithEntities); -// addSimpleServiceMessage(text, realId); -// -// const auto detachExistingItem = false; -// const auto body = history->createItem( -// history->nextNonHistoryEntryId(), -// PrepareLogMessage(action.vnew_message(), date), -// MessageFlag::AdminLogEntry, -// detachExistingItem); -// if (oldValue.text.isEmpty()) { -// oldValue = PrepareText( -// QString(), -// tr::lng_admin_log_empty_text(tr::now)); -// } -// -// body->addLogEntryOriginal( -// id, -// (canHaveCaption -// ? tr::lng_admin_log_previous_caption -// : tr::lng_admin_log_previous_message)(tr::now), -// oldValue); -// addPart(body, sentDate, realId); -// }; -// -// const auto createDeleteMessage = [&](const LogDelete &action) -// { -// const auto realId = ExtractRealMsgId(action.vmessage()); -// const auto text = tr::lng_admin_log_deleted_message( -// tr::now, -// lt_from, -// fromLinkText, -// Ui::Text::WithEntities); -// addSimpleServiceMessage(text, realId); -// -// const auto detachExistingItem = false; -// addPart( -// history->createItem( -// history->nextNonHistoryEntryId(), -// PrepareLogMessage(action.vmessage(), date), -// MessageFlag::AdminLogEntry, -// detachExistingItem), -// ExtractSentDate(action.vmessage()), -// realId); -// }; -// -// const auto createParticipantJoin = [&](const LogJoin &) -// { -// const auto text = (channel->isMegagroup() -// ? tr::lng_admin_log_participant_joined -// : tr::lng_admin_log_participant_joined_channel)( -// tr::now, -// lt_from, -// fromLinkText, -// Ui::Text::WithEntities); -// addSimpleServiceMessage(text); -// }; -// -// const auto createParticipantLeave = [&](const LogLeave &) -// { -// const auto text = (channel->isMegagroup() -// ? tr::lng_admin_log_participant_left -// : tr::lng_admin_log_participant_left_channel)( -// tr::now, -// lt_from, -// fromLinkText, -// Ui::Text::WithEntities); -// addSimpleServiceMessage(text); -// }; -// -// const auto createParticipantInvite = [&](const LogInvite &action) -// { -// addSimpleTextMessage( -// GenerateParticipantChangeText(channel, action.vparticipant())); -// }; -// -// const auto createParticipantToggleBan = [&](const LogBan &action) -// { -// addSimpleTextMessage( -// GenerateParticipantChangeText( -// channel, -// action.vnew_participant(), -// action.vprev_participant())); -// }; -// -// const auto createParticipantToggleAdmin = [&](const LogPromote &action) -// { -// if ((action.vnew_participant().type() == mtpc_channelParticipantAdmin) -// && (action.vprev_participant().type() -// == mtpc_channelParticipantCreator)) { -// // In case of ownership transfer we show that message in -// // the "User > Creator" part and skip the "Creator > Admin" part. -// return; -// } -// addSimpleTextMessage( -// GenerateParticipantChangeText( -// channel, -// action.vnew_participant(), -// action.vprev_participant())); -// }; -// -// const auto createChangeStickerSet = [&](const LogSticker &action) -// { -// const auto set = action.vnew_stickerset(); -// const auto removed = (set.type() == mtpc_inputStickerSetEmpty); -// if (removed) { -// const auto text = tr::lng_admin_log_removed_stickers_group( -// tr::now, -// lt_from, -// fromLinkText, -// Ui::Text::WithEntities); -// addSimpleServiceMessage(text); -// } -// else { -// const auto text = tr::lng_admin_log_changed_stickers_group( -// tr::now, -// lt_from, -// fromLinkText, -// lt_sticker_set, -// Ui::Text::Link( -// tr::lng_admin_log_changed_stickers_set(tr::now), -// QString()), -// Ui::Text::WithEntities); -// const auto setLink = std::make_shared([=]( -// ClickContext context) -// { -// const auto my = context.other -// .value(); -// if (const auto -// controller = my.sessionWindow.get()) { -// controller->show( -// Box( -// controller->uiShow(), -// Data::FromInputSet(set), -// Data::StickersType::Stickers), -// Ui::LayerOption::CloseOther); -// } -// }); -// auto message = PreparedServiceText{text}; -// message.links.push_back(fromLink); -// message.links.push_back(setLink); -// addPart(history->makeMessage( -// history->nextNonHistoryEntryId(), -// MessageFlag::AdminLogEntry, -// date, -// std::move(message), -// peerToUser(from->id))); -// } -// }; -// -// const auto createTogglePreHistoryHidden = [&]( -// const LogPreHistory &action) -// { -// const auto hidden = (action.vnew_value().type() == mtpc_boolTrue); -// const auto text = (hidden -// ? tr::lng_admin_log_history_made_hidden -// : tr::lng_admin_log_history_made_visible)( -// tr::now, -// lt_from, -// fromLinkText, -// Ui::Text::WithEntities); -// addSimpleServiceMessage(text); -// }; -// -// const auto createDefaultBannedRights = [&]( -// const LogPermissions &action) -// { -// addSimpleTextMessage( -// GenerateDefaultBannedRightsChangeText( -// channel, -// ChatRestrictionsInfo(action.vnew_banned_rights()), -// ChatRestrictionsInfo(action.vprev_banned_rights()))); -// }; -// -// const auto createStopPoll = [&](const LogPoll &action) -// { -// const auto realId = ExtractRealMsgId(action.vmessage()); -// const auto text = tr::lng_admin_log_stopped_poll( -// tr::now, -// lt_from, -// fromLinkText, -// Ui::Text::WithEntities); -// addSimpleServiceMessage(text, realId); -// -// const auto detachExistingItem = false; -// addPart( -// history->createItem( -// history->nextNonHistoryEntryId(), -// PrepareLogMessage(action.vmessage(), date), -// MessageFlag::AdminLogEntry, -// detachExistingItem), -// ExtractSentDate(action.vmessage()), -// realId); -// }; -// -// const auto createChangeLinkedChat = [&](const LogDiscussion &action) -// { -// const auto now = history->owner().channelLoaded( -// action.vnew_value().v); -// if (!now) { -// const auto text = (broadcast -// ? tr::lng_admin_log_removed_linked_chat -// : tr::lng_admin_log_removed_linked_channel)( -// tr::now, -// lt_from, -// fromLinkText, -// Ui::Text::WithEntities); -// addSimpleServiceMessage(text); -// } -// else { -// const auto text = (broadcast -// ? tr::lng_admin_log_changed_linked_chat -// : tr::lng_admin_log_changed_linked_channel)( -// tr::now, -// lt_from, -// fromLinkText, -// lt_chat, -// Ui::Text::Link(now->name(), QString()), -// Ui::Text::WithEntities); -// const auto chatLink = std::make_shared([=] -// { -// if (const auto window = -// now->session().tryResolveWindow()) { -// window->showPeerHistory(now); -// } -// }); -// auto message = PreparedServiceText{text}; -// message.links.push_back(fromLink); -// message.links.push_back(chatLink); -// addPart(history->makeMessage( -// history->nextNonHistoryEntryId(), -// MessageFlag::AdminLogEntry, -// date, -// std::move(message), -// peerToUser(from->id))); -// } -// }; -// -// const auto createChangeLocation = [&](const LogLocation &action) -// { -// action.vnew_value().match([&](const MTPDchannelLocation &data) -// { -// const auto address = qs(data.vaddress()); -// const auto link = data.vgeo_point().match([&]( -// const MTPDgeoPoint &data) -// { -// return Ui::Text::Link( -// address, -// LocationClickHandler::Url(Data::LocationPoint( -// data))); -// }, [&](const MTPDgeoPointEmpty &) -// { -// return TextWithEntities{.text = address}; -// }); -// const auto text = tr::lng_admin_log_changed_location_chat( -// tr::now, -// lt_from, -// fromLinkText, -// lt_address, -// link, -// Ui::Text::WithEntities); -// addSimpleServiceMessage(text); -// }, [&](const MTPDchannelLocationEmpty &) -// { -// const auto text = tr::lng_admin_log_removed_location_chat( -// tr::now, -// lt_from, -// fromLinkText, -// Ui::Text::WithEntities); -// addSimpleServiceMessage(text); -// }); -// }; -// -// const auto createToggleSlowMode = [&](const LogSlowMode &action) -// { -// if (const auto seconds = action.vnew_value().v) { -// const auto duration = (seconds >= 60) -// ? tr::lng_minutes(tr::now, lt_count, seconds / 60) -// : tr::lng_seconds(tr::now, lt_count, seconds); -// const auto text = tr::lng_admin_log_changed_slow_mode( -// tr::now, -// lt_from, -// fromLinkText, -// lt_duration, -// {.text = duration}, -// Ui::Text::WithEntities); -// addSimpleServiceMessage(text); -// } -// else { -// const auto text = tr::lng_admin_log_removed_slow_mode( -// tr::now, -// lt_from, -// fromLinkText, -// Ui::Text::WithEntities); -// addSimpleServiceMessage(text); -// } -// }; -// -// const auto createStartGroupCall = [&](const LogStartCall &data) -// { -// const auto text = (broadcast -// ? tr::lng_admin_log_started_group_call_channel -// : tr::lng_admin_log_started_group_call)( -// tr::now, -// lt_from, -// fromLinkText, -// Ui::Text::WithEntities); -// addSimpleServiceMessage(text); -// }; -// -// const auto createDiscardGroupCall = [&](const LogDiscardCall &data) -// { -// const auto text = (broadcast -// ? tr::lng_admin_log_discarded_group_call_channel -// : tr::lng_admin_log_discarded_group_call)( -// tr::now, -// lt_from, -// fromLinkText, -// Ui::Text::WithEntities); -// addSimpleServiceMessage(text); -// }; -// -// const auto groupCallParticipantPeer = [&]( -// const MTPGroupCallParticipant &data) -// { -// return data.match([&](const MTPDgroupCallParticipant &data) -// { -// return history->owner().peer(peerFromMTP(data.vpeer())); -// }); -// }; -// -// const auto addServiceMessageWithLink = [&]( -// const TextWithEntities &text, -// const ClickHandlerPtr &link) -// { -// auto message = PreparedServiceText{text}; -// message.links.push_back(fromLink); -// message.links.push_back(link); -// addPart(history->makeMessage( -// history->nextNonHistoryEntryId(), -// MessageFlag::AdminLogEntry, -// date, -// std::move(message), -// peerToUser(from->id))); -// }; -// -// const auto createParticipantMute = [&](const LogMute &data) -// { -// const auto participantPeer = groupCallParticipantPeer( -// data.vparticipant()); -// const auto participantPeerLink = participantPeer->createOpenLink(); -// const auto participantPeerLinkText = Ui::Text::Link( -// participantPeer->name(), -// QString()); -// const auto text = (broadcast -// ? tr::lng_admin_log_muted_participant_channel -// : tr::lng_admin_log_muted_participant)( -// tr::now, -// lt_from, -// fromLinkText, -// lt_user, -// participantPeerLinkText, -// Ui::Text::WithEntities); -// addServiceMessageWithLink(text, participantPeerLink); -// }; -// -// const auto createParticipantUnmute = [&](const LogUnmute &data) -// { -// const auto participantPeer = groupCallParticipantPeer( -// data.vparticipant()); -// const auto participantPeerLink = participantPeer->createOpenLink(); -// const auto participantPeerLinkText = Ui::Text::Link( -// participantPeer->name(), -// QString()); -// const auto text = (broadcast -// ? tr::lng_admin_log_unmuted_participant_channel -// : tr::lng_admin_log_unmuted_participant)( -// tr::now, -// lt_from, -// fromLinkText, -// lt_user, -// participantPeerLinkText, -// Ui::Text::WithEntities); -// addServiceMessageWithLink(text, participantPeerLink); -// }; -// -// const auto createToggleGroupCallSetting = [&]( -// const LogCallSetting &data) -// { -// const auto text = (mtpIsTrue(data.vjoin_muted()) -// ? (broadcast -// ? tr::lng_admin_log_disallowed_unmute_self_channel -// : tr::lng_admin_log_disallowed_unmute_self) -// : (broadcast -// ? tr::lng_admin_log_allowed_unmute_self_channel -// : tr::lng_admin_log_allowed_unmute_self))( -// tr::now, -// lt_from, -// fromLinkText, -// Ui::Text::WithEntities); -// addSimpleServiceMessage(text); -// }; -// -// const auto addInviteLinkServiceMessage = [&]( -// const TextWithEntities &text, -// const MTPExportedChatInvite &data, -// ClickHandlerPtr additional = nullptr) -// { -// auto message = PreparedServiceText{text}; -// message.links.push_back(fromLink); -// if (!ExtractInviteLink(data).endsWith(Ui::kQEllipsis)) { -// message.links.push_back(std::make_shared( -// InternalInviteLinkUrl(data))); -// } -// if (additional) { -// message.links.push_back(std::move(additional)); -// } -// addPart(history->makeMessage( -// history->nextNonHistoryEntryId(), -// MessageFlag::AdminLogEntry, -// date, -// std::move(message), -// peerToUser(from->id), -// nullptr)); -// }; -// -// const auto createParticipantJoinByInvite = [&]( -// const LogJoinByInvite &data) -// { -// const auto text = data.is_via_chatlist() -// ? (channel->isMegagroup() -// ? tr::lng_admin_log_participant_joined_by_filter_link -// : tr::lng_admin_log_participant_joined_by_filter_link_channel) -// : (channel->isMegagroup() -// ? tr::lng_admin_log_participant_joined_by_link -// : tr::lng_admin_log_participant_joined_by_link_channel); -// addInviteLinkServiceMessage( -// text( -// tr::now, -// lt_from, -// fromLinkText, -// lt_link, -// GenerateInviteLinkLink(data.vinvite()), -// Ui::Text::WithEntities), -// data.vinvite()); -// }; -// -// const auto createExportedInviteDelete = [&](const LogInviteDelete &data) -// { -// addInviteLinkServiceMessage( -// tr::lng_admin_log_delete_invite_link( -// tr::now, -// lt_from, -// fromLinkText, -// lt_link, -// GenerateInviteLinkLink(data.vinvite()), -// Ui::Text::WithEntities), -// data.vinvite()); -// }; -// -// const auto createExportedInviteRevoke = [&](const LogInviteRevoke &data) -// { -// addInviteLinkServiceMessage( -// tr::lng_admin_log_revoke_invite_link( -// tr::now, -// lt_from, -// fromLinkText, -// lt_link, -// GenerateInviteLinkLink(data.vinvite()), -// Ui::Text::WithEntities), -// data.vinvite()); -// }; -// -// const auto createExportedInviteEdit = [&](const LogInviteEdit &data) -// { -// addSimpleTextMessage( -// GenerateInviteLinkChangeText( -// data.vnew_invite(), -// data.vprev_invite())); -// }; -// -// const auto createParticipantVolume = [&](const LogVolume &data) -// { -// const auto participantPeer = groupCallParticipantPeer( -// data.vparticipant()); -// const auto participantPeerLink = participantPeer->createOpenLink(); -// const auto participantPeerLinkText = Ui::Text::Link( -// participantPeer->name(), -// QString()); -// const auto volume = data.vparticipant().match([&]( -// const MTPDgroupCallParticipant &data) -// { -// return data.vvolume().value_or(10000); -// }); -// const auto volumeText = QString::number(volume / 100) + '%'; -// auto text = (broadcast -// ? tr::lng_admin_log_participant_volume_channel -// : tr::lng_admin_log_participant_volume)( -// tr::now, -// lt_from, -// fromLinkText, -// lt_user, -// participantPeerLinkText, -// lt_percent, -// {.text = volumeText}, -// Ui::Text::WithEntities); -// addServiceMessageWithLink(text, participantPeerLink); -// }; -// -// const auto createChangeHistoryTTL = [&](const LogTTL &data) -// { -// const auto was = data.vprev_value().v; -// const auto now = data.vnew_value().v; -// const auto wrap = [](int duration) -> TextWithEntities -// { -// const auto text = (duration == 5) -// ? u"5 seconds"_q -// : Ui::FormatTTL(duration); -// return {.text = text}; -// }; -// const auto text = !was -// ? tr::lng_admin_log_messages_ttl_set( -// tr::now, -// lt_from, -// fromLinkText, -// lt_duration, -// wrap(now), -// Ui::Text::WithEntities) -// : !now -// ? tr::lng_admin_log_messages_ttl_removed( -// tr::now, -// lt_from, -// fromLinkText, -// lt_duration, -// wrap(was), -// Ui::Text::WithEntities) -// : tr::lng_admin_log_messages_ttl_changed( -// tr::now, -// lt_from, -// fromLinkText, -// lt_previous, -// wrap(was), -// lt_duration, -// wrap(now), -// Ui::Text::WithEntities); -// addSimpleServiceMessage(text); -// }; -// -// const auto createParticipantJoinByRequest = [&]( -// const LogJoinByRequest &data) -// { -// const auto user = channel->owner().user(UserId(data.vapproved_by())); -// const auto linkText = GenerateInviteLinkLink(data.vinvite()); -// const auto text = (linkText.text == PublicJoinLink()) -// ? (channel->isMegagroup() -// ? tr::lng_admin_log_participant_approved_by_request -// : tr::lng_admin_log_participant_approved_by_request_channel)( -// tr::now, -// lt_from, -// fromLinkText, -// lt_user, -// Ui::Text::Link(user->name(), QString()), -// Ui::Text::WithEntities) -// : (channel->isMegagroup() -// ? tr::lng_admin_log_participant_approved_by_link -// : tr::lng_admin_log_participant_approved_by_link_channel)( -// tr::now, -// lt_from, -// fromLinkText, -// lt_link, -// linkText, -// lt_user, -// Ui::Text::Link(user->name(), QString()), -// Ui::Text::WithEntities); -// addInviteLinkServiceMessage( -// text, -// data.vinvite(), -// user->createOpenLink()); -// }; -// -// const auto createToggleNoForwards = [&](const LogNoForwards &data) -// { -// const auto disabled = (data.vnew_value().type() == mtpc_boolTrue); -// const auto text = (disabled -// ? tr::lng_admin_log_forwards_disabled -// : tr::lng_admin_log_forwards_enabled)( -// tr::now, -// lt_from, -// fromLinkText, -// Ui::Text::WithEntities); -// addSimpleServiceMessage(text); -// }; -// -// const auto createSendMessage = [&](const LogSendMessage &data) -// { -// const auto realId = ExtractRealMsgId(data.vmessage()); -// const auto text = tr::lng_admin_log_sent_message( -// tr::now, -// lt_from, -// fromLinkText, -// Ui::Text::WithEntities); -// addSimpleServiceMessage(text, realId); -// -// const auto detachExistingItem = false; -// addPart( -// history->createItem( -// history->nextNonHistoryEntryId(), -// PrepareLogMessage(data.vmessage(), date), -// MessageFlag::AdminLogEntry, -// detachExistingItem), -// ExtractSentDate(data.vmessage()), -// realId); -// }; -// -// const auto createChangeAvailableReactions = [&]( -// const LogChangeAvailableReactions &data) -// { -// const auto text = data.vnew_value().match([&]( -// const MTPDchatReactionsNone &) -// { -// return tr::lng_admin_log_reactions_disabled( -// tr::now, -// lt_from, -// fromLinkText, -// Ui::Text::WithEntities); -// }, [&](const MTPDchatReactionsSome &data) -// { -// using namespace Window::Notifications; -// auto list = TextWithEntities(); -// for (const auto &one : data.vreactions().v) { -// if (!list.empty()) { -// list.append(", "); -// } -// list.append(Manager::ComposeReactionEmoji( -// session, -// Data::ReactionFromMTP(one))); -// } -// return tr::lng_admin_log_reactions_updated( -// tr::now, -// lt_from, -// fromLinkText, -// lt_emoji, -// list, -// Ui::Text::WithEntities); -// }, [&](const MTPDchatReactionsAll &data) -// { -// return (data.is_allow_custom() -// ? tr::lng_admin_log_reactions_allowed_all -// : tr::lng_admin_log_reactions_allowed_official)( -// tr::now, -// lt_from, -// fromLinkText, -// Ui::Text::WithEntities); -// }); -// addSimpleServiceMessage(text); -// }; -// -// const auto createChangeUsernames = [&](const LogChangeUsernames &data) -// { -// const auto newValue = data.vnew_value().v; -// const auto oldValue = data.vprev_value().v; -// -// const auto list = [&](const auto &tlList) -// { -// auto result = TextWithEntities(); -// for (const auto &tlValue : tlList) { -// result.append(PrepareText( -// history->session().createInternalLinkFull(qs(tlValue)), -// QString())); -// result.append('\n'); -// } -// return result; -// }; -// -// if (newValue.size() == oldValue.size()) { -// if (newValue.size() == 1) { -// const auto tl = MTP_channelAdminLogEventActionChangeUsername( -// newValue.front(), -// oldValue.front()); -// tl.match([&](const LogUsername &data) -// { -// createChangeUsername(data); -// }, [](const auto &) -// { -// }); -// return; -// } -// else { -// const auto wasReordered = [&] -// { -// for (const auto &newLink : newValue) { -// if (!ranges::contains(oldValue, newLink)) { -// return false; -// } -// } -// return true; -// }(); -// if (wasReordered) { -// addSimpleServiceMessage((channel->isMegagroup() -// ? tr::lng_admin_log_reordered_link_group -// : tr::lng_admin_log_reordered_link_channel)( -// tr::now, -// lt_from, -// fromLinkText, -// Ui::Text::WithEntities)); -// const auto body = makeSimpleTextMessage(list(newValue)); -// body->addLogEntryOriginal( -// id, -// tr::lng_admin_log_previous_links_order(tr::now), -// list(oldValue)); -// addPart(body); -// return; -// } -// } -// } -// else if (std::abs(newValue.size() - oldValue.size()) == 1) { -// const auto activated = newValue.size() > oldValue.size(); -// const auto changed = [&] -// { -// const auto value = activated ? oldValue : newValue; -// for (const auto &link : (activated ? newValue : oldValue)) { -// if (!ranges::contains(value, link)) { -// return qs(link); -// } -// } -// return QString(); -// }(); -// addSimpleServiceMessage((activated -// ? tr::lng_admin_log_activated_link -// : tr::lng_admin_log_deactivated_link)( -// tr::now, -// lt_from, -// fromLinkText, -// lt_link, -// {changed}, -// Ui::Text::WithEntities)); -// return; -// } -// // Probably will never happen. -// auto resultText = fromLinkText; -// addSimpleServiceMessage(resultText.append({ -// .text = channel->isMegagroup() -// ? u" changed list of group links:"_q -// : u" changed list of channel links:"_q, -// })); -// const auto body = makeSimpleTextMessage(list(newValue)); -// body->addLogEntryOriginal( -// id, -// "Previous links", -// list(oldValue)); -// addPart(body); -// }; -// -// const auto createToggleForum = [&](const LogToggleForum &data) -// { -// const auto enabled = (data.vnew_value().type() == mtpc_boolTrue); -// const auto text = (enabled -// ? tr::lng_admin_log_topics_enabled -// : tr::lng_admin_log_topics_disabled)( -// tr::now, -// lt_from, -// fromLinkText, -// Ui::Text::WithEntities); -// addSimpleServiceMessage(text); -// }; -// -// const auto createCreateTopic = [&](const LogCreateTopic &data) -// { -// auto topicLink = GenerateTopicLink(channel, data.vtopic()); -// addSimpleServiceMessage(tr::lng_admin_log_topics_created( -// tr::now, -// lt_from, -// fromLinkText, -// lt_topic, -// topicLink, -// Ui::Text::WithEntities)); -// }; -// -// const auto createEditTopic = [&](const LogEditTopic &data) -// { -// const auto prevLink = GenerateTopicLink(channel, data.vprev_topic()); -// const auto nowLink = GenerateTopicLink(channel, data.vnew_topic()); -// if (prevLink != nowLink) { -// addSimpleServiceMessage(tr::lng_admin_log_topics_changed( -// tr::now, -// lt_from, -// fromLinkText, -// lt_topic, -// prevLink, -// lt_new_topic, -// nowLink, -// Ui::Text::WithEntities)); -// } -// const auto wasClosed = IsTopicClosed(data.vprev_topic()); -// const auto nowClosed = IsTopicClosed(data.vnew_topic()); -// if (nowClosed != wasClosed) { -// addSimpleServiceMessage((nowClosed -// ? tr::lng_admin_log_topics_closed -// : tr::lng_admin_log_topics_reopened)( -// tr::now, -// lt_from, -// fromLinkText, -// lt_topic, -// nowLink, -// Ui::Text::WithEntities)); -// } -// const auto wasHidden = IsTopicHidden(data.vprev_topic()); -// const auto nowHidden = IsTopicHidden(data.vnew_topic()); -// if (nowHidden != wasHidden) { -// addSimpleServiceMessage((nowHidden -// ? tr::lng_admin_log_topics_hidden -// : tr::lng_admin_log_topics_unhidden)( -// tr::now, -// lt_from, -// fromLinkText, -// lt_topic, -// nowLink, -// Ui::Text::WithEntities)); -// } -// }; -// -// const auto createDeleteTopic = [&](const LogDeleteTopic &data) -// { -// auto topicLink = GenerateTopicLink(channel, data.vtopic()); -// if (!topicLink.entities.empty()) { -// topicLink.entities.erase(topicLink.entities.begin()); -// } -// addSimpleServiceMessage(tr::lng_admin_log_topics_deleted( -// tr::now, -// lt_from, -// fromLinkText, -// lt_topic, -// topicLink, -// Ui::Text::WithEntities)); -// }; -// -// const auto createPinTopic = [&](const LogPinTopic &data) -// { -// if (const auto &topic = data.vnew_topic()) { -// auto topicLink = GenerateTopicLink(channel, *topic); -// addSimpleServiceMessage(tr::lng_admin_log_topics_pinned( -// tr::now, -// lt_from, -// fromLinkText, -// lt_topic, -// topicLink, -// Ui::Text::WithEntities)); -// } -// else if (const auto &previous = data.vprev_topic()) { -// auto topicLink = GenerateTopicLink(channel, *previous); -// addSimpleServiceMessage(tr::lng_admin_log_topics_unpinned( -// tr::now, -// lt_from, -// fromLinkText, -// lt_topic, -// topicLink, -// Ui::Text::WithEntities)); -// } -// }; -// -// const auto createToggleAntiSpam = [&](const LogToggleAntiSpam &data) -// { -// const auto enabled = (data.vnew_value().type() == mtpc_boolTrue); -// const auto text = (enabled -// ? tr::lng_admin_log_antispam_enabled -// : tr::lng_admin_log_antispam_disabled)( -// tr::now, -// lt_from, -// fromLinkText, -// Ui::Text::WithEntities); -// addSimpleServiceMessage(text); -// }; -// -// action.match( -// createChangeTitle, -// createChangeAbout, -// createChangeUsername, -// createChangePhoto, -// createToggleInvites, -// createToggleSignatures, -// createUpdatePinned, -// createEditMessage, -// createDeleteMessage, -// createParticipantJoin, -// createParticipantLeave, -// createParticipantInvite, -// createParticipantToggleBan, -// createParticipantToggleAdmin, -// createChangeStickerSet, -// createTogglePreHistoryHidden, -// createDefaultBannedRights, -// createStopPoll, -// createChangeLinkedChat, -// createChangeLocation, -// createToggleSlowMode, -// createStartGroupCall, -// createDiscardGroupCall, -// createParticipantMute, -// createParticipantUnmute, -// createToggleGroupCallSetting, -// createParticipantJoinByInvite, -// createExportedInviteDelete, -// createExportedInviteRevoke, -// createExportedInviteEdit, -// createParticipantVolume, -// createChangeHistoryTTL, -// createParticipantJoinByRequest, -// createToggleNoForwards, -// createSendMessage, -// createChangeAvailableReactions, -// createChangeUsernames, -// createToggleForum, -// createCreateTopic, -// createEditTopic, -// createDeleteTopic, -// createPinTopic, -// createToggleAntiSpam); } } // namespace EditedLog diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index 43fe722a0..ac6548980 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -258,7 +258,7 @@ std::unique_ptr HistoryItem::CreateMedia( }); }, [&](const MTPDmessageMediaDocument &media) -> Result { const auto document = media.vdocument(); - if (media.vttl_seconds() && false) { // AyuGram: show expiring messages + if (false) { // AyuGram: show expiring messages LOG(("App Error: " "Unexpected MTPMessageMediaDocument " "with ttl_seconds in CreateMedia.")); @@ -371,7 +371,7 @@ HistoryItem::HistoryItem( setServiceText({ tr::lng_message_empty(tr::now, Ui::Text::WithEntities) }); - } else if (checked == MediaCheckResult::HasTimeToLive && false) { // AyuGram: show expiring messages + } else if (checked == MediaCheckResult::HasExpiredMediaTimeToLive) { createServiceFromMtp(data); applyTTL(data); } else if (checked == MediaCheckResult::HasStoryMention) { @@ -382,7 +382,7 @@ HistoryItem::HistoryItem( createComponents(data); if (media) { setMedia(*media); - if (checked == MediaCheckResult::HasTimeToLive) { + if (checked == MediaCheckResult::HasUnsupportedTimeToLive) { media->match([&](const MTPDmessageMediaPhoto &media) { auto time = media.vttl_seconds()->v; setAyuHint(formatTTL(time)); diff --git a/Telegram/lib_ui b/Telegram/lib_ui index f6495b479..b63dcdb35 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit f6495b47950b0b42a9519769eff6c6deab9fc97a +Subproject commit b63dcdb357f9905be45dd30debc419ac4194422f