Use can_delete_dialog in delete_dialog_history.
This commit is contained in:
parent
ddbfc45925
commit
f2dead72ca
@ -11059,8 +11059,7 @@ void MessagesManager::delete_dialog_history(DialogId dialog_id, bool remove_from
|
|||||||
return promise.set_error(Status::Error(400, "Can't delete the chat"));
|
return promise.set_error(Status::Error(400, "Can't delete the chat"));
|
||||||
}
|
}
|
||||||
if (!remove_from_dialog_list) {
|
if (!remove_from_dialog_list) {
|
||||||
return promise.set_error(
|
return promise.set_error(Status::Error(400, "Can't delete chat history without removing the chat"));
|
||||||
Status::Error(400, "Can't delete only chat history without removing the chat from the chat list"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
removed_sponsored_dialog_id_ = dialog_id;
|
removed_sponsored_dialog_id_ = dialog_id;
|
||||||
@ -11071,37 +11070,25 @@ void MessagesManager::delete_dialog_history(DialogId dialog_id, bool remove_from
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto dialog_type = dialog_id.get_type();
|
auto can_delete = can_delete_dialog(d);
|
||||||
switch (dialog_type) {
|
|
||||||
case DialogType::User:
|
|
||||||
case DialogType::Chat:
|
|
||||||
// ok
|
|
||||||
break;
|
|
||||||
case DialogType::Channel:
|
|
||||||
if (revoke) {
|
if (revoke) {
|
||||||
if (!td_->contacts_manager_->get_channel_can_be_deleted(d->dialog_id.get_channel_id())) {
|
if (!can_delete.for_all_users_) {
|
||||||
return promise.set_error(Status::Error(400, "Can't delete chat history for all chat members"));
|
if (!can_delete.for_self_) {
|
||||||
|
return promise.set_error(Status::Error(400, "Chat history can't be deleted"));
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG(INFO) << "Can't delete history of " << dialog_id << " for everyone; delete it only for self";
|
||||||
|
revoke = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (is_broadcast_channel(dialog_id)) {
|
if (!can_delete.for_self_) {
|
||||||
return promise.set_error(Status::Error(400, "Can't delete chat history in a channel"));
|
return promise.set_error(
|
||||||
|
Status::Error(400, PSLICE() << "Can't delete history of " << dialog_id << " only for self"));
|
||||||
}
|
}
|
||||||
if (td_->contacts_manager_->is_channel_public(dialog_id.get_channel_id())) {
|
|
||||||
return promise.set_error(Status::Error(400, "Can't delete chat history in a public supergroup"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case DialogType::SecretChat:
|
|
||||||
// ok
|
|
||||||
break;
|
|
||||||
case DialogType::None:
|
|
||||||
default:
|
|
||||||
UNREACHABLE();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto last_new_message_id = d->last_new_message_id;
|
auto last_new_message_id = d->last_new_message_id;
|
||||||
if (dialog_type != DialogType::SecretChat && last_new_message_id == MessageId()) {
|
if (dialog_id.get_type() != DialogType::SecretChat && last_new_message_id == MessageId()) {
|
||||||
// TODO get dialog from the server and delete history from last message identifier
|
// TODO get dialog from the server and delete history from last message identifier
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user