Allow report private chats with users sharing their location.

GitOrigin-RevId: f1b546ea71a534436e487d4a644b4001bd274e09
This commit is contained in:
levlam 2020-02-12 03:05:54 +03:00
parent 190419bf8b
commit 9964c011ec
5 changed files with 13 additions and 6 deletions

View File

@ -4076,7 +4076,7 @@ deleteAccount reason:string = Ok;
//@description Removes a chat action bar without any other action @chat_id Chat identifier
removeChatActionBar chat_id:int53 = Ok;
//@description Reports a chat to the Telegram moderators. Supported only for supergroups, channels, or private chats with bots, since other chats can't be checked by moderators, or when the report is done from the chat action bar @chat_id Chat identifier @reason The reason for reporting the chat @message_ids Identifiers of reported messages, if any
//@description Reports a chat to the Telegram moderators. A chat can be reported only from the chat action bar, or if this is a private chats with a bot, a private chat with a user sharing their location, a supergroup, or a channel, since other chats can't be checked by moderators @chat_id Chat identifier @reason The reason for reporting the chat @message_ids Identifiers of reported messages, if any
reportChat chat_id:int53 reason:ChatReportReason message_ids:vector<int53> = Ok;

View File

@ -4928,6 +4928,7 @@ void ContactsManager::on_update_peer_located(vector<tl_object_ptr<telegram_api::
td_->messages_manager_->force_create_dialog(dialog_id, "on_update_peer_located");
if (from_update) {
CHECK(dialog_type == DialogType::User);
bool is_found = false;
for (auto &dialog_nearby : users_nearby_) {
if (dialog_nearby.dialog_id == dialog_id) {
@ -4941,11 +4942,16 @@ void ContactsManager::on_update_peer_located(vector<tl_object_ptr<telegram_api::
}
if (!is_found) {
users_nearby_.emplace_back(dialog_id, distance);
all_users_nearby_.insert(dialog_id.get_user_id());
need_update = true;
}
} else {
auto &dialogs_nearby = dialog_type == DialogType::User ? users_nearby_ : channels_nearby_;
dialogs_nearby.emplace_back(dialog_id, distance);
if (dialog_type == DialogType::User) {
users_nearby_.emplace_back(dialog_id, distance);
all_users_nearby_.insert(dialog_id.get_user_id());
} else {
channels_nearby_.emplace_back(dialog_id, distance);
}
}
}
if (need_update) {
@ -10966,7 +10972,7 @@ bool ContactsManager::is_user_status_exact(UserId user_id) const {
bool ContactsManager::can_report_user(UserId user_id) const {
auto u = get_user(user_id);
return u != nullptr && !u->is_deleted && u->is_bot && !u->is_support;
return u != nullptr && !u->is_deleted && !u->is_support && (u->is_bot || all_users_nearby_.count(user_id) != 0);
}
const ContactsManager::User *ContactsManager::get_user(UserId user_id) const {

View File

@ -1425,6 +1425,7 @@ class ContactsManager : public Actor {
vector<DialogNearby> users_nearby_;
vector<DialogNearby> channels_nearby_;
std::unordered_set<UserId, UserIdHash> all_users_nearby_;
std::unordered_map<ChannelId, ChannelId, ChannelIdHash> linked_channel_ids_;

View File

@ -6942,7 +6942,7 @@ void MessagesManager::report_dialog(DialogId dialog_id, const tl_object_ptr<td_a
}
if (reason == nullptr) {
return promise.set_error(Status::Error(3, "Reason shouldn't be empty"));
return promise.set_error(Status::Error(3, "Reason must not be empty"));
}
Dialog *user_d = d;

View File

@ -3509,7 +3509,7 @@ void StickersManager::reorder_installed_sticker_sets(bool is_masks, const vector
Result<std::tuple<FileId, bool, bool>> StickersManager::prepare_input_sticker(td_api::inputSticker *sticker) {
if (sticker == nullptr) {
return Status::Error(3, "Input sticker shouldn't be empty");
return Status::Error(3, "Input sticker must not be empty");
}
if (!clean_input_string(sticker->emojis_)) {