diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index d802bdbc4..b18bb9560 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -1141,6 +1141,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_report_group_title" = "Report group"; "lng_report_bot_title" = "Report bot"; "lng_report_message_title" = "Report message"; +"lng_report_profile_photo_title" = "Report profile photo"; +"lng_report_profile_video_title" = "Report profile video"; "lng_report_please_select_messages" = "Please select messages to report."; "lng_report_select_messages" = "Select messages"; "lng_report_messages_none" = "Select Messages"; @@ -2053,6 +2055,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_mediaview_yesterday" = "yesterday at {time}"; "lng_mediaview_date_time" = "{date} at {time}"; "lng_mediaview_set_userpic" = "Set as Main"; +"lng_mediaview_report_profile_photo" = "Report"; "lng_mediaview_saved_to" = "Image was saved to your {downloads} folder"; "lng_mediaview_downloads" = "Downloads"; diff --git a/Telegram/SourceFiles/api/api_report.cpp b/Telegram/SourceFiles/api/api_report.cpp index 29c5a7118..3b607f3d2 100644 --- a/Telegram/SourceFiles/api/api_report.cpp +++ b/Telegram/SourceFiles/api/api_report.cpp @@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "apiwrap.h" #include "data/data_peer.h" +#include "data/data_photo.h" #include "lang/lang_keys.h" #include "main/main_session.h" #include "ui/boxes/report_box.h" @@ -42,16 +43,17 @@ void SendReport( not_null peer, Ui::ReportReason reason, const QString &comment, - MessageIdsList ids) { - if (ids.empty()) { + std::variant> data) { + auto done = [=] { + Ui::Toast::Show(toastParent, tr::lng_report_thanks(tr::now)); + }; + v::match(data, [&](v::null_t) { peer->session().api().request(MTPaccount_ReportPeer( peer->input, ReasonToTL(reason), MTP_string(comment) - )).done([=] { - Ui::Toast::Show(toastParent, tr::lng_report_thanks(tr::now)); - }).send(); - } else { + )).done(std::move(done)).send(); + }, [&](const MessageIdsList &ids) { auto apiIds = QVector(); apiIds.reserve(ids.size()); for (const auto &fullId : ids) { @@ -62,10 +64,15 @@ void SendReport( MTP_vector(apiIds), ReasonToTL(reason), MTP_string(comment) - )).done([=] { - Ui::Toast::Show(toastParent, tr::lng_report_thanks(tr::now)); - }).send(); - } + )).done(std::move(done)).send(); + }, [&](not_null photo) { + peer->session().api().request(MTPaccount_ReportProfilePhoto( + peer->input, + photo->mtpInput(), + ReasonToTL(reason), + MTP_string(comment) + )).done(std::move(done)).send(); + }); } } // namespace Api diff --git a/Telegram/SourceFiles/api/api_report.h b/Telegram/SourceFiles/api/api_report.h index c134e0db0..9472221e3 100644 --- a/Telegram/SourceFiles/api/api_report.h +++ b/Telegram/SourceFiles/api/api_report.h @@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #pragma once class PeerData; +class PhotoData; namespace Ui { enum class ReportReason; @@ -20,6 +21,6 @@ void SendReport( not_null peer, Ui::ReportReason reason, const QString &comment, - MessageIdsList ids = {}); + std::variant> data); } // namespace Api diff --git a/Telegram/SourceFiles/boxes/report_messages_box.cpp b/Telegram/SourceFiles/boxes/report_messages_box.cpp index 9d5e3ab0d..01836105f 100644 --- a/Telegram/SourceFiles/boxes/report_messages_box.cpp +++ b/Telegram/SourceFiles/boxes/report_messages_box.cpp @@ -9,23 +9,34 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "api/api_report.h" #include "data/data_peer.h" +#include "data/data_photo.h" #include "lang/lang_keys.h" #include "ui/boxes/report_box.h" #include "ui/layers/generic_box.h" #include "window/window_session_controller.h" -object_ptr ReportItemsBox( +namespace { + +[[nodiscard]] object_ptr Report( not_null peer, - MessageIdsList ids) { + std::variant> data) { + const auto source = v::match(data, [](const MessageIdsList &ids) { + return Ui::ReportSource::Message; + }, [](not_null photo) { + return photo->hasVideo() + ? Ui::ReportSource::ProfileVideo + : Ui::ReportSource::ProfilePhoto; + }, [](v::null_t) { + Unexpected("Bad source report."); + return Ui::ReportSource::Bot; + }); return Box([=](not_null box) { - using Source = Ui::ReportSource; - using Reason = Ui::ReportReason; - Ui::ReportReasonBox(box, Source::Message, [=](Reason reason) { + Ui::ReportReasonBox(box, source, [=](Ui::ReportReason reason) { Ui::BoxShow(box).showBox(Box([=](not_null box) { const auto show = Ui::BoxShow(box); Ui::ReportDetailsBox(box, [=](const QString &text) { const auto toastParent = show.toastParent(); - Api::SendReport(toastParent, peer, reason, text, ids); + Api::SendReport(toastParent, peer, reason, text, data); show.hideLayer(); }); })); @@ -33,6 +44,20 @@ object_ptr ReportItemsBox( }); } +} // namespace + +object_ptr ReportItemsBox( + not_null peer, + MessageIdsList ids) { + return Report(peer, ids); +} + +object_ptr ReportProfilePhotoBox( + not_null peer, + not_null photo) { + return Report(peer, photo); +} + void ShowReportPeerBox( not_null window, not_null peer) { diff --git a/Telegram/SourceFiles/boxes/report_messages_box.h b/Telegram/SourceFiles/boxes/report_messages_box.h index 30a1a73dc..9cd4c95a6 100644 --- a/Telegram/SourceFiles/boxes/report_messages_box.h +++ b/Telegram/SourceFiles/boxes/report_messages_box.h @@ -23,6 +23,9 @@ class PeerData; [[nodiscard]] object_ptr ReportItemsBox( not_null peer, MessageIdsList ids); +[[nodiscard]] object_ptr ReportProfilePhotoBox( + not_null peer, + not_null photo); void ShowReportPeerBox( not_null window, not_null peer); diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp index 8cdb88f86..f70325dcb 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp +++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp @@ -32,6 +32,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/gl/gl_surface.h" #include "ui/boxes/confirm_box.h" #include "boxes/delete_messages_box.h" +#include "boxes/report_messages_box.h" #include "media/audio/media_audio.h" #include "media/view/media_view_playback_controls.h" #include "media/view/media_view_group_thumbs.h" @@ -1034,6 +1035,25 @@ void OverlayWidget::fillContextMenuActions(const MenuCallback &addAction) { peer->session().api().peerPhoto().set(peer, photo); }, &st::mediaMenuIconProfile); }(); + [&] { // Report userpic. + if (!_peer + || !_photo + || _peer->isSelf() + || _peer->isNotificationsUser() + || !userPhotosKey()) { + return; + } + const auto photo = _photo; + const auto peer = _peer; + addAction(tr::lng_mediaview_report_profile_photo(tr::now), [=] { + if (const auto window = findWindow()) { + close(); + window->show( + ReportProfilePhotoBox(peer, photo), + Ui::LayerOption::CloseOther); + } + }, &st::mediaMenuIconReport); + }(); } auto OverlayWidget::computeOverviewType() const diff --git a/Telegram/SourceFiles/ui/boxes/report_box.cpp b/Telegram/SourceFiles/ui/boxes/report_box.cpp index f124a114e..8dbe0f87a 100644 --- a/Telegram/SourceFiles/ui/boxes/report_box.cpp +++ b/Telegram/SourceFiles/ui/boxes/report_box.cpp @@ -40,9 +40,15 @@ void ReportReasonBox( case Source::Channel: return tr::lng_report_title(); case Source::Group: return tr::lng_report_group_title(); case Source::Bot: return tr::lng_report_bot_title(); + case Source::ProfilePhoto: + return tr::lng_report_profile_photo_title(); + case Source::ProfileVideo: + return tr::lng_report_profile_video_title(); } Unexpected("'source' in ReportReasonBox."); }()); + const auto isProfileSource = (source == Source::ProfilePhoto) + || (source == Source::ProfileVideo); auto margin = style::margins{ 0, st::reportReasonTopSkip, 0, 0 }; const auto add = [&]( Reason reason, @@ -69,7 +75,7 @@ void ReportReasonBox( }); }; add(Reason::Spam, tr::lng_report_reason_spam, st::menuIconDelete); - if (source != Source::Message) { + if (source != Source::Message && !isProfileSource) { add(Reason::Fake, tr::lng_report_reason_fake, st::menuIconFake); } add( diff --git a/Telegram/SourceFiles/ui/boxes/report_box.h b/Telegram/SourceFiles/ui/boxes/report_box.h index bc4ddbd35..691ecd4a1 100644 --- a/Telegram/SourceFiles/ui/boxes/report_box.h +++ b/Telegram/SourceFiles/ui/boxes/report_box.h @@ -16,6 +16,8 @@ enum class ReportSource { Channel, Group, Bot, + ProfilePhoto, + ProfileVideo, }; enum class ReportReason { diff --git a/Telegram/SourceFiles/ui/menu_icons.style b/Telegram/SourceFiles/ui/menu_icons.style index 310e698f2..50f005fa4 100644 --- a/Telegram/SourceFiles/ui/menu_icons.style +++ b/Telegram/SourceFiles/ui/menu_icons.style @@ -131,6 +131,7 @@ mediaMenuIconForward: icon {{ "menu/forward", mediaviewMenuFg }}; mediaMenuIconDelete: icon {{ "menu/delete", mediaviewMenuFg }}; mediaMenuIconShowAll: icon {{ "menu/all_media", mediaviewMenuFg }}; mediaMenuIconProfile: icon {{ "menu/profile", mediaviewMenuFg }}; +mediaMenuIconReport: icon {{ "menu/report", mediaviewMenuFg }}; menuIconStartStream: icon {{ "menu/start_stream", menuIconColor }}; menuIconStartStreamWith: icon {{ "menu/start_stream_with", menuIconColor }};