Add canSendMessageToUser.only_local.

This commit is contained in:
levlam 2024-01-26 14:06:27 +03:00
parent 3391c643f3
commit aa6be7d9bf
4 changed files with 7 additions and 6 deletions

View File

@ -9538,8 +9538,10 @@ setNewChatPrivacySettings settings:newChatPrivacySettings = Ok;
getNewChatPrivacySettings = NewChatPrivacySettings;
//@description Check whether the current user can message another user or try to create a chat with them @user_id Identifier of the other user
canSendMessageToUser user_id:int53 = CanSendMessageToUserResult;
//@description Check whether the current user can message another user or try to create a chat with them
//@user_id Identifier of the other user
//@only_local Pass true to get only locally available information without sending network requests
canSendMessageToUser user_id:int53 only_local:Bool = CanSendMessageToUserResult;
//@description Returns the value of an option by its name. (Check the list of available options on https://core.telegram.org/tdlib/options.) Can be called before authorization. Can be called synchronously for options "version" and "commit_hash"

View File

@ -5561,7 +5561,6 @@ void ContactsManager::can_send_message_to_user(
}
if (force) {
LOG(ERROR) << "Can't check " << user_id << " message privacy settings";
return promise.set_value(td_api::make_object<td_api::canSendMessageToUserResultOk>());
}

View File

@ -6531,7 +6531,7 @@ void Td::on_request(uint64 id, td_api::setNewChatPrivacySettings &request) {
void Td::on_request(uint64 id, const td_api::canSendMessageToUser &request) {
CHECK_IS_USER();
CREATE_REQUEST_PROMISE();
contacts_manager_->can_send_message_to_user(UserId(request.user_id_), false, std::move(promise));
contacts_manager_->can_send_message_to_user(UserId(request.user_id_), request.only_local_, std::move(promise));
}
void Td::on_request(uint64 id, td_api::setChatTitle &request) {

View File

@ -5449,10 +5449,10 @@ class CliClient final : public Actor {
get_args(args, allow_new_chats_from_unknown_users);
auto settings = td_api::make_object<td_api::newChatPrivacySettings>(allow_new_chats_from_unknown_users);
send_request(td_api::make_object<td_api::setNewChatPrivacySettings>(std::move(settings)));
} else if (op == "csmtu") {
} else if (op == "csmtu" || op == "csmtul") {
UserId user_id;
get_args(args, user_id);
send_request(td_api::make_object<td_api::canSendMessageToUser>(user_id));
send_request(td_api::make_object<td_api::canSendMessageToUser>(user_id, op == "csmtul"));
} else if (op == "sct") {
ChatId chat_id;
string title;