Added ability to report chat photo and channel photo.

This commit is contained in:
23rd 2022-10-20 17:50:58 +03:00 committed by John Preston
parent f0177bc6cc
commit 6d3f9017fa
5 changed files with 48 additions and 9 deletions

View file

@ -1304,6 +1304,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_report_message_title" = "Report message";
"lng_report_profile_photo_title" = "Report profile photo";
"lng_report_profile_video_title" = "Report profile video";
"lng_report_group_photo_title" = "Report group photo";
"lng_report_group_video_title" = "Report group video";
"lng_report_channel_photo_title" = "Report channel photo";
"lng_report_channel_video_title" = "Report channel video";
"lng_report_please_select_messages" = "Please select messages to report.";
"lng_report_select_messages" = "Select messages";
"lng_report_messages_none" = "Select Messages";

View file

@ -22,10 +22,18 @@ namespace {
std::variant<v::null_t, MessageIdsList, not_null<PhotoData*>> data) {
const auto source = v::match(data, [](const MessageIdsList &ids) {
return Ui::ReportSource::Message;
}, [](not_null<PhotoData*> photo) {
return photo->hasVideo()
? Ui::ReportSource::ProfileVideo
: Ui::ReportSource::ProfilePhoto;
}, [&](not_null<PhotoData*> photo) {
return peer->isUser()
? (photo->hasVideo()
? Ui::ReportSource::ProfileVideo
: Ui::ReportSource::ProfilePhoto)
: (peer->isChat() || (peer->isChannel() && peer->isMegagroup()))
? (photo->hasVideo()
? Ui::ReportSource::GroupVideo
: Ui::ReportSource::GroupPhoto)
: (photo->hasVideo()
? Ui::ReportSource::ChannelVideo
: Ui::ReportSource::ChannelPhoto);
}, [](v::null_t) {
Unexpected("Bad source report.");
return Ui::ReportSource::Bot;

View file

@ -1034,11 +1034,28 @@ void OverlayWidget::fillContextMenuActions(const MenuCallback &addAction) {
}, &st::mediaMenuIconProfile);
}();
[&] { // Report userpic.
if (!_peer
|| !_photo
|| _peer->isSelf()
|| _peer->isNotificationsUser()
|| !userPhotosKey()) {
if (!_peer || !_photo ) {
return;
}
using Type = SharedMediaType;
if (userPhotosKey()) {
if (_peer->isSelf() || _peer->isNotificationsUser()) {
return;
}
} else if ((sharedMediaType().value_or(Type::File) == Type::ChatPhoto)
|| (_peer->userpicPhotoId() == _photo->id)) {
if (const auto chat = _peer->asChat()) {
if (chat->canEditInformation()) {
return;
}
} else if (const auto channel = _peer->asChannel()) {
if (channel->canEditInformation()) {
return;
}
} else {
return;
}
} else {
return;
}
const auto photo = _photo;

View file

@ -44,6 +44,12 @@ void ReportReasonBox(
return tr::lng_report_profile_photo_title();
case Source::ProfileVideo:
return tr::lng_report_profile_video_title();
case Source::GroupPhoto: return tr::lng_report_group_photo_title();
case Source::GroupVideo: return tr::lng_report_group_video_title();
case Source::ChannelPhoto:
return tr::lng_report_channel_photo_title();
case Source::ChannelVideo:
return tr::lng_report_channel_video_title();
}
Unexpected("'source' in ReportReasonBox.");
}());

View file

@ -18,6 +18,10 @@ enum class ReportSource {
Bot,
ProfilePhoto,
ProfileVideo,
GroupPhoto,
GroupVideo,
ChannelPhoto,
ChannelVideo,
};
enum class ReportReason {