Merge remote-tracking branch 'td/master'
This commit is contained in:
commit
f211df073e
@ -52,10 +52,10 @@ authenticationCodeTypeSms length:int32 = AuthenticationCodeType;
|
|||||||
//@description An authentication code is delivered via a phone call to the specified phone number @length Length of the code
|
//@description An authentication code is delivered via a phone call to the specified phone number @length Length of the code
|
||||||
authenticationCodeTypeCall length:int32 = AuthenticationCodeType;
|
authenticationCodeTypeCall length:int32 = AuthenticationCodeType;
|
||||||
|
|
||||||
//@description An authentication code is delivered by an immediately canceled call to the specified phone number. The phone number from which the call was made is the code that must be entered automatically @pattern Pattern of the phone number from which the call will be made
|
//@description An authentication code is delivered by an immediately canceled call to the specified phone number. The phone number, from which the call was made, is the code that must be entered automatically @pattern Pattern of the phone number from which the call will be made
|
||||||
authenticationCodeTypeFlashCall pattern:string = AuthenticationCodeType;
|
authenticationCodeTypeFlashCall pattern:string = AuthenticationCodeType;
|
||||||
|
|
||||||
//@description An authentication code is delivered by an immediately canceled call to the specified phone number. The phone number from which the call was made is the code that is supposed to be entered manually by the user @phone_number_prefix Prefix of the phone number from which the call will be made @length Number of digits in the code, excluding the prefix
|
//@description An authentication code is delivered by an immediately canceled call to the specified phone number. The phone number, from which the call was made, is the code that is supposed to be entered manually by the user @phone_number_prefix Prefix of the phone number from which the call will be made @length Number of digits in the code, excluding the prefix
|
||||||
authenticationCodeTypeMissedCall phone_number_prefix:string length:int32 = AuthenticationCodeType;
|
authenticationCodeTypeMissedCall phone_number_prefix:string length:int32 = AuthenticationCodeType;
|
||||||
|
|
||||||
|
|
||||||
@ -2365,7 +2365,7 @@ call id:int32 user_id:int53 is_outgoing:Bool is_video:Bool state:CallState = Cal
|
|||||||
//@allow_missed_call Pass true if the authentication code may be sent via a missed call to the specified phone number
|
//@allow_missed_call Pass true if the authentication code may be sent via a missed call to the specified phone number
|
||||||
//@is_current_phone_number Pass true if the authenticated phone number is used on the current device
|
//@is_current_phone_number Pass true if the authenticated phone number is used on the current device
|
||||||
//@allow_sms_retriever_api For official applications only. True, if the application can use Android SMS Retriever API (requires Google Play Services >= 10.2) to automatically receive the authentication code from the SMS. See https://developers.google.com/identity/sms-retriever/ for more details
|
//@allow_sms_retriever_api For official applications only. True, if the application can use Android SMS Retriever API (requires Google Play Services >= 10.2) to automatically receive the authentication code from the SMS. See https://developers.google.com/identity/sms-retriever/ for more details
|
||||||
//@authentication_tokens List of authentication tokens, received in updateOption("authentication_token") in previously logged out sessions
|
//@authentication_tokens List of up to 20 authentication tokens, recently received in updateOption("authentication_token") in previously logged out sessions
|
||||||
phoneNumberAuthenticationSettings allow_flash_call:Bool allow_missed_call:Bool is_current_phone_number:Bool allow_sms_retriever_api:Bool authentication_tokens:vector<string> = PhoneNumberAuthenticationSettings;
|
phoneNumberAuthenticationSettings allow_flash_call:Bool allow_missed_call:Bool is_current_phone_number:Bool allow_sms_retriever_api:Bool authentication_tokens:vector<string> = PhoneNumberAuthenticationSettings;
|
||||||
|
|
||||||
|
|
||||||
@ -3488,7 +3488,7 @@ suggestedActionCheckPassword = SuggestedAction;
|
|||||||
//@description Suggests the user to check whether authorization phone number is correct and change the phone number if it is inaccessible
|
//@description Suggests the user to check whether authorization phone number is correct and change the phone number if it is inaccessible
|
||||||
suggestedActionCheckPhoneNumber = SuggestedAction;
|
suggestedActionCheckPhoneNumber = SuggestedAction;
|
||||||
|
|
||||||
//@description Suggests the user to see a hint about meaning of one and two ticks on sent message
|
//@description Suggests the user to see a hint about meaning of one and two ticks on sent messages
|
||||||
suggestedActionSeeTicksHint = SuggestedAction;
|
suggestedActionSeeTicksHint = SuggestedAction;
|
||||||
|
|
||||||
//@description Suggests the user to convert specified supergroup to a broadcast group @supergroup_id Supergroup identifier
|
//@description Suggests the user to convert specified supergroup to a broadcast group @supergroup_id Supergroup identifier
|
||||||
@ -5132,9 +5132,6 @@ setGroupCallTitle group_call_id:int32 title:string = Ok;
|
|||||||
//@group_call_id Group call identifier @mute_new_participants New value of the mute_new_participants setting
|
//@group_call_id Group call identifier @mute_new_participants New value of the mute_new_participants setting
|
||||||
toggleGroupCallMuteNewParticipants group_call_id:int32 mute_new_participants:Bool = Ok;
|
toggleGroupCallMuteNewParticipants group_call_id:int32 mute_new_participants:Bool = Ok;
|
||||||
|
|
||||||
//@description Revokes invite link for a group call. Requires groupCall.can_be_managed group call flag @group_call_id Group call identifier
|
|
||||||
revokeGroupCallInviteLink group_call_id:int32 = Ok;
|
|
||||||
|
|
||||||
//@description Invites users to an active group call. Sends a service message of type messageInviteToGroupCall for video chats
|
//@description Invites users to an active group call. Sends a service message of type messageInviteToGroupCall for video chats
|
||||||
//@group_call_id Group call identifier @user_ids User identifiers. At most 10 users can be invited simultaneously
|
//@group_call_id Group call identifier @user_ids User identifiers. At most 10 users can be invited simultaneously
|
||||||
inviteGroupCallParticipants group_call_id:int32 user_ids:vector<int53> = Ok;
|
inviteGroupCallParticipants group_call_id:int32 user_ids:vector<int53> = Ok;
|
||||||
@ -5144,6 +5141,9 @@ inviteGroupCallParticipants group_call_id:int32 user_ids:vector<int53> = Ok;
|
|||||||
//@can_self_unmute Pass true if the invite link needs to contain an invite hash, passing which to joinGroupCall would allow the invited user to unmute themselves. Requires groupCall.can_be_managed group call flag
|
//@can_self_unmute Pass true if the invite link needs to contain an invite hash, passing which to joinGroupCall would allow the invited user to unmute themselves. Requires groupCall.can_be_managed group call flag
|
||||||
getGroupCallInviteLink group_call_id:int32 can_self_unmute:Bool = HttpUrl;
|
getGroupCallInviteLink group_call_id:int32 can_self_unmute:Bool = HttpUrl;
|
||||||
|
|
||||||
|
//@description Revokes invite link for a group call. Requires groupCall.can_be_managed group call flag @group_call_id Group call identifier
|
||||||
|
revokeGroupCallInviteLink group_call_id:int32 = Ok;
|
||||||
|
|
||||||
//@description Starts recording of an active group call. Requires groupCall.can_be_managed group call flag @group_call_id Group call identifier @title Group call recording title; 0-64 characters
|
//@description Starts recording of an active group call. Requires groupCall.can_be_managed group call flag @group_call_id Group call identifier @title Group call recording title; 0-64 characters
|
||||||
//@record_video Pass true to record a video file instead of an audio file @use_portrait_orientation Pass true to use portrait orientation for video instead of landscape one
|
//@record_video Pass true to record a video file instead of an audio file @use_portrait_orientation Pass true to use portrait orientation for video instead of landscape one
|
||||||
startGroupCallRecording group_call_id:int32 title:string record_video:Bool use_portrait_orientation:Bool = Ok;
|
startGroupCallRecording group_call_id:int32 title:string record_video:Bool use_portrait_orientation:Bool = Ok;
|
||||||
@ -5439,7 +5439,7 @@ toggleSupergroupIsAllHistoryAvailable supergroup_id:int53 is_all_history_availab
|
|||||||
//@description Upgrades supergroup to a broadcast group; requires owner privileges in the supergroup @supergroup_id Identifier of the supergroup
|
//@description Upgrades supergroup to a broadcast group; requires owner privileges in the supergroup @supergroup_id Identifier of the supergroup
|
||||||
toggleSupergroupIsBroadcastGroup supergroup_id:int53 = Ok;
|
toggleSupergroupIsBroadcastGroup supergroup_id:int53 = Ok;
|
||||||
|
|
||||||
//@description Reports some messages from a message sender in a supergroup as spam; requires administrator rights in the supergroup @supergroup_id Supergroup identifier @message_ids Identifiers of messages sent in the supergroup. All messages must be sent by the same sender. This list must be non-empty
|
//@description Reports messages in a supergroup as spam; requires administrator rights in the supergroup @supergroup_id Supergroup identifier @message_ids Identifiers of messages to report
|
||||||
reportSupergroupSpam supergroup_id:int53 message_ids:vector<int53> = Ok;
|
reportSupergroupSpam supergroup_id:int53 message_ids:vector<int53> = Ok;
|
||||||
|
|
||||||
//@description Returns information about members or banned users in a supergroup or channel. Can be used only if supergroupFullInfo.can_get_members == true; additionally, administrator privileges may be required for some filters @supergroup_id Identifier of the supergroup or channel
|
//@description Returns information about members or banned users in a supergroup or channel. Can be used only if supergroupFullInfo.can_get_members == true; additionally, administrator privileges may be required for some filters @supergroup_id Identifier of the supergroup or channel
|
||||||
@ -5720,7 +5720,7 @@ checkPhoneNumberConfirmationCode code:string = Ok;
|
|||||||
setBotUpdatesStatus pending_update_count:int32 error_message:string = Ok;
|
setBotUpdatesStatus pending_update_count:int32 error_message:string = Ok;
|
||||||
|
|
||||||
|
|
||||||
//@description Uploads a PNG image with a sticker; returns the uploaded file @user_id Sticker file owner; ignored for regular users @sticker Sticker file to upload
|
//@description Uploads a file with a sticker; returns the uploaded file @user_id Sticker file owner; ignored for regular users @sticker Sticker file to upload
|
||||||
uploadStickerFile user_id:int53 sticker:InputSticker = File;
|
uploadStickerFile user_id:int53 sticker:InputSticker = File;
|
||||||
|
|
||||||
//@description Returns a suggested name for a new sticker set with a given title @title Sticker set title; 1-64 characters
|
//@description Returns a suggested name for a new sticker set with a given title @title Sticker set title; 1-64 characters
|
||||||
|
@ -690,7 +690,7 @@ void AuthManager::on_log_out_result(NetQueryPtr &result) {
|
|||||||
on_query_ok();
|
on_query_ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void AuthManager::on_authorization_lost(const string &source) {
|
void AuthManager::on_authorization_lost(string source) {
|
||||||
LOG(WARNING) << "Lost authorization because of " << source;
|
LOG(WARNING) << "Lost authorization because of " << source;
|
||||||
destroy_auth_keys();
|
destroy_auth_keys();
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ class AuthManager final : public NetActor {
|
|||||||
|
|
||||||
void on_update_login_token();
|
void on_update_login_token();
|
||||||
|
|
||||||
void on_authorization_lost(const string &source);
|
void on_authorization_lost(string source);
|
||||||
void on_closing(bool destroy_flag);
|
void on_closing(bool destroy_flag);
|
||||||
|
|
||||||
// can return nullptr if state isn't initialized yet
|
// can return nullptr if state isn't initialized yet
|
||||||
|
@ -6666,13 +6666,11 @@ void ContactsManager::report_channel_spam(ChannelId channel_id, const vector<Mes
|
|||||||
if (!c->is_megagroup) {
|
if (!c->is_megagroup) {
|
||||||
return promise.set_error(Status::Error(400, "Spam can be reported only in supergroups"));
|
return promise.set_error(Status::Error(400, "Spam can be reported only in supergroups"));
|
||||||
}
|
}
|
||||||
|
if (!c->status.is_administrator()) {
|
||||||
if (message_ids.empty()) {
|
return promise.set_error(Status::Error(400, "Spam can be reported only by chat administrators"));
|
||||||
return promise.set_error(Status::Error(400, "Message list is empty"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DialogId sender_dialog_id;
|
std::unordered_map<DialogId, vector<MessageId>, DialogIdHash> server_message_ids;
|
||||||
vector<MessageId> server_message_ids;
|
|
||||||
for (auto &message_id : message_ids) {
|
for (auto &message_id : message_ids) {
|
||||||
if (message_id.is_valid_scheduled()) {
|
if (message_id.is_valid_scheduled()) {
|
||||||
return promise.set_error(Status::Error(400, "Can't report scheduled messages"));
|
return promise.set_error(Status::Error(400, "Can't report scheduled messages"));
|
||||||
@ -6686,34 +6684,25 @@ void ContactsManager::report_channel_spam(ChannelId channel_id, const vector<Mes
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto current_sender_dialog_id = td_->messages_manager_->get_message_sender({DialogId(channel_id), message_id});
|
auto sender_dialog_id = td_->messages_manager_->get_dialog_message_sender({DialogId(channel_id), message_id});
|
||||||
if (!current_sender_dialog_id.is_valid()) {
|
if (sender_dialog_id.is_valid() && sender_dialog_id != DialogId(get_my_id()) &&
|
||||||
continue;
|
td_->messages_manager_->have_input_peer(sender_dialog_id, AccessRights::Know)) {
|
||||||
|
server_message_ids[sender_dialog_id].push_back(message_id);
|
||||||
}
|
}
|
||||||
if (sender_dialog_id.is_valid()) {
|
|
||||||
if (current_sender_dialog_id != sender_dialog_id) {
|
|
||||||
return promise.set_error(Status::Error(400, "All messages nust be from the same sender"));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
sender_dialog_id = current_sender_dialog_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
server_message_ids.push_back(message_id);
|
|
||||||
}
|
}
|
||||||
if (server_message_ids.empty()) {
|
if (server_message_ids.empty()) {
|
||||||
return promise.set_value(Unit());
|
return promise.set_value(Unit());
|
||||||
}
|
}
|
||||||
CHECK(sender_dialog_id.is_valid());
|
|
||||||
|
|
||||||
if (!td_->messages_manager_->have_input_peer(sender_dialog_id, AccessRights::Know)) {
|
MultiPromiseActorSafe mpas{"ReportSupergroupSpamMultiPromiseActor"};
|
||||||
return promise.set_error(Status::Error(400, "Have no access to the user"));
|
mpas.add_promise(std::move(promise));
|
||||||
}
|
auto lock_promise = mpas.get_promise();
|
||||||
if (sender_dialog_id == DialogId(get_my_id())) {
|
|
||||||
return promise.set_error(Status::Error(400, "Can't report self"));
|
for (auto &it : server_message_ids) {
|
||||||
|
td_->create_handler<ReportChannelSpamQuery>(mpas.get_promise())->send(channel_id, it.first, it.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
td_->create_handler<ReportChannelSpamQuery>(std::move(promise))
|
lock_promise.set_value(Unit());
|
||||||
->send(channel_id, sender_dialog_id, server_message_ids);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContactsManager::delete_chat(ChatId chat_id, Promise<Unit> &&promise) {
|
void ContactsManager::delete_chat(ChatId chat_id, Promise<Unit> &&promise) {
|
||||||
|
@ -11001,9 +11001,8 @@ void MessagesManager::delete_dialog_messages_by_sender(DialogId dialog_id, Dialo
|
|||||||
}
|
}
|
||||||
|
|
||||||
vector<MessageId> message_ids;
|
vector<MessageId> message_ids;
|
||||||
find_messages(d->messages.get(), message_ids, [sender_dialog_id](const Message *m) {
|
find_messages(d->messages.get(), message_ids,
|
||||||
return sender_dialog_id == MessagesManager::get_message_sender(m);
|
[sender_dialog_id](const Message *m) { return sender_dialog_id == get_message_sender(m); });
|
||||||
});
|
|
||||||
|
|
||||||
vector<int64> deleted_message_ids;
|
vector<int64> deleted_message_ids;
|
||||||
bool need_update_dialog_pos = false;
|
bool need_update_dialog_pos = false;
|
||||||
@ -17148,8 +17147,8 @@ void MessagesManager::on_get_blocked_dialogs(int32 offset, int32 limit, int32 to
|
|||||||
promise.set_value(td_api::make_object<td_api::messageSenders>(total_count, std::move(senders)));
|
promise.set_value(td_api::make_object<td_api::messageSenders>(total_count, std::move(senders)));
|
||||||
}
|
}
|
||||||
|
|
||||||
DialogId MessagesManager::get_message_sender(FullMessageId full_message_id) {
|
DialogId MessagesManager::get_dialog_message_sender(FullMessageId full_message_id) {
|
||||||
const auto *m = get_message_force(full_message_id, "get_message_sender");
|
const auto *m = get_message_force(full_message_id, "get_dialog_message_sender");
|
||||||
if (m == nullptr) {
|
if (m == nullptr) {
|
||||||
return DialogId();
|
return DialogId();
|
||||||
}
|
}
|
||||||
|
@ -569,7 +569,7 @@ class MessagesManager final : public Actor {
|
|||||||
|
|
||||||
bool can_get_message_statistics(FullMessageId full_message_id);
|
bool can_get_message_statistics(FullMessageId full_message_id);
|
||||||
|
|
||||||
DialogId get_message_sender(FullMessageId full_message_id);
|
DialogId get_dialog_message_sender(FullMessageId full_message_id);
|
||||||
|
|
||||||
bool have_message_force(FullMessageId full_message_id, const char *source);
|
bool have_message_force(FullMessageId full_message_id, const char *source);
|
||||||
|
|
||||||
|
@ -3269,7 +3269,7 @@ bool Td::is_internal_config_option(Slice name) {
|
|||||||
return name == "revoke_pm_inbox" || name == "revoke_time_limit" || name == "revoke_pm_time_limit" ||
|
return name == "revoke_pm_inbox" || name == "revoke_time_limit" || name == "revoke_pm_time_limit" ||
|
||||||
name == "rating_e_decay" || name == "recent_stickers_limit";
|
name == "rating_e_decay" || name == "recent_stickers_limit";
|
||||||
case 's':
|
case 's':
|
||||||
return name == "saved_animations_limit";
|
return name == "saved_animations_limit" || name == "session_count";
|
||||||
case 'v':
|
case 'v':
|
||||||
return name == "video_note_size_max";
|
return name == "video_note_size_max";
|
||||||
case 'w':
|
case 'w':
|
||||||
@ -3283,96 +3283,158 @@ void Td::on_config_option_updated(const string &name) {
|
|||||||
if (close_flag_) {
|
if (close_flag_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (name == "auth") {
|
switch (name[0]) {
|
||||||
send_closure(auth_manager_actor_, &AuthManager::on_authorization_lost,
|
case 'a':
|
||||||
G()->shared_config().get_option_string(name));
|
if (name == "animated_emoji_zoom") {
|
||||||
return;
|
// nothing to do: animated emoji zoom is updated only at launch
|
||||||
} else if (name == "saved_animations_limit") {
|
}
|
||||||
return animations_manager_->on_update_saved_animations_limit(
|
if (name == "animation_search_emojis") {
|
||||||
narrow_cast<int32>(G()->shared_config().get_option_integer(name)));
|
animations_manager_->on_update_animation_search_emojis(G()->shared_config().get_option_string(name));
|
||||||
} else if (name == "animation_search_emojis") {
|
}
|
||||||
return animations_manager_->on_update_animation_search_emojis(G()->shared_config().get_option_string(name));
|
if (name == "animation_search_provider") {
|
||||||
} else if (name == "animation_search_provider") {
|
animations_manager_->on_update_animation_search_provider(G()->shared_config().get_option_string(name));
|
||||||
return animations_manager_->on_update_animation_search_provider(G()->shared_config().get_option_string(name));
|
}
|
||||||
} else if (name == "animated_emoji_zoom") {
|
if (name == "auth") {
|
||||||
// update animated emoji zoom only at launch
|
send_closure(auth_manager_actor_, &AuthManager::on_authorization_lost,
|
||||||
return;
|
G()->shared_config().get_option_string(name));
|
||||||
} else if (name == "recent_stickers_limit") {
|
}
|
||||||
return stickers_manager_->on_update_recent_stickers_limit(
|
break;
|
||||||
narrow_cast<int32>(G()->shared_config().get_option_integer(name)));
|
case 'b':
|
||||||
} else if (name == "favorite_stickers_limit") {
|
if (name == "base_language_pack_version") {
|
||||||
stickers_manager_->on_update_favorite_stickers_limit(
|
send_closure(language_pack_manager_, &LanguagePackManager::on_language_pack_version_changed, true, -1);
|
||||||
narrow_cast<int32>(G()->shared_config().get_option_integer(name)));
|
}
|
||||||
} else if (name == "disable_animated_emoji") {
|
break;
|
||||||
stickers_manager_->on_update_disable_animated_emojis();
|
case 'c':
|
||||||
} else if (name == "my_id") {
|
if (name == "connection_parameters") {
|
||||||
G()->set_my_id(G()->shared_config().get_option_integer(name));
|
if (G()->mtproto_header().set_parameters(G()->shared_config().get_option_string(name))) {
|
||||||
} else if (name == "otherwise_relogin_days") {
|
G()->net_query_dispatcher().update_mtproto_header();
|
||||||
auto days = narrow_cast<int32>(G()->shared_config().get_option_integer(name));
|
}
|
||||||
if (days > 0) {
|
}
|
||||||
vector<SuggestedAction> added_actions{SuggestedAction{SuggestedAction::Type::SetPassword, DialogId(), days}};
|
break;
|
||||||
send_closure(G()->td(), &Td::send_update, get_update_suggested_actions_object(added_actions, {}));
|
case 'd':
|
||||||
}
|
if (name == "dice_emojis") {
|
||||||
return;
|
send_closure(stickers_manager_actor_, &StickersManager::on_update_dice_emojis);
|
||||||
} else if (name == "session_count") {
|
}
|
||||||
G()->net_query_dispatcher().update_session_count();
|
if (name == "dice_success_values") {
|
||||||
} else if (name == "use_pfs") {
|
send_closure(stickers_manager_actor_, &StickersManager::on_update_dice_success_values);
|
||||||
G()->net_query_dispatcher().update_use_pfs();
|
}
|
||||||
} else if (name == "use_storage_optimizer") {
|
if (name == "disable_animated_emoji") {
|
||||||
send_closure(storage_manager_, &StorageManager::update_use_storage_optimizer);
|
stickers_manager_->on_update_disable_animated_emojis();
|
||||||
} else if (name == "rating_e_decay") {
|
}
|
||||||
return send_closure(top_dialog_manager_actor_, &TopDialogManager::update_rating_e_decay);
|
if (name == "disable_contact_registered_notifications") {
|
||||||
} else if (name == "disable_contact_registered_notifications") {
|
send_closure(notification_manager_actor_,
|
||||||
send_closure(notification_manager_actor_,
|
&NotificationManager::on_disable_contact_registered_notifications_changed);
|
||||||
&NotificationManager::on_disable_contact_registered_notifications_changed);
|
}
|
||||||
} else if (name == "disable_top_chats") {
|
if (name == "disable_top_chats") {
|
||||||
send_closure(top_dialog_manager_actor_, &TopDialogManager::update_is_enabled,
|
send_closure(top_dialog_manager_actor_, &TopDialogManager::update_is_enabled,
|
||||||
!G()->shared_config().get_option_boolean(name));
|
!G()->shared_config().get_option_boolean(name));
|
||||||
} else if (name == "connection_parameters") {
|
}
|
||||||
if (G()->mtproto_header().set_parameters(G()->shared_config().get_option_string(name))) {
|
break;
|
||||||
G()->net_query_dispatcher().update_mtproto_header();
|
case 'e':
|
||||||
}
|
if (name == "emoji_sounds") {
|
||||||
} else if (name == "is_emulator") {
|
send_closure(stickers_manager_actor_, &StickersManager::on_update_emoji_sounds);
|
||||||
if (G()->mtproto_header().set_is_emulator(G()->shared_config().get_option_boolean(name))) {
|
}
|
||||||
G()->net_query_dispatcher().update_mtproto_header();
|
break;
|
||||||
}
|
case 'f':
|
||||||
} else if (name == "localization_target") {
|
if (name == "favorite_stickers_limit") {
|
||||||
send_closure(language_pack_manager_, &LanguagePackManager::on_language_pack_changed);
|
stickers_manager_->on_update_favorite_stickers_limit(
|
||||||
if (G()->mtproto_header().set_language_pack(G()->shared_config().get_option_string(name))) {
|
narrow_cast<int32>(G()->shared_config().get_option_integer(name)));
|
||||||
G()->net_query_dispatcher().update_mtproto_header();
|
}
|
||||||
}
|
break;
|
||||||
} else if (name == "language_pack_id") {
|
case 'i':
|
||||||
send_closure(language_pack_manager_, &LanguagePackManager::on_language_code_changed);
|
if (name == "ignored_restriction_reasons") {
|
||||||
if (G()->mtproto_header().set_language_code(G()->shared_config().get_option_string(name))) {
|
send_closure(contacts_manager_actor_, &ContactsManager::on_ignored_restriction_reasons_changed);
|
||||||
G()->net_query_dispatcher().update_mtproto_header();
|
}
|
||||||
}
|
if (name == "is_emulator") {
|
||||||
} else if (name == "language_pack_version") {
|
if (G()->mtproto_header().set_is_emulator(G()->shared_config().get_option_boolean(name))) {
|
||||||
return send_closure(language_pack_manager_, &LanguagePackManager::on_language_pack_version_changed, false, -1);
|
G()->net_query_dispatcher().update_mtproto_header();
|
||||||
} else if (name == "base_language_pack_version") {
|
}
|
||||||
return send_closure(language_pack_manager_, &LanguagePackManager::on_language_pack_version_changed, true, -1);
|
}
|
||||||
} else if (name == "utc_time_offset") {
|
break;
|
||||||
if (G()->mtproto_header().set_tz_offset(static_cast<int32>(G()->shared_config().get_option_integer(name)))) {
|
case 'l':
|
||||||
G()->net_query_dispatcher().update_mtproto_header();
|
if (name == "language_pack_id") {
|
||||||
}
|
send_closure(language_pack_manager_, &LanguagePackManager::on_language_code_changed);
|
||||||
} else if (name == "notification_group_count_max") {
|
if (G()->mtproto_header().set_language_code(G()->shared_config().get_option_string(name))) {
|
||||||
send_closure(notification_manager_actor_, &NotificationManager::on_notification_group_count_max_changed, true);
|
G()->net_query_dispatcher().update_mtproto_header();
|
||||||
} else if (name == "notification_group_size_max") {
|
}
|
||||||
send_closure(notification_manager_actor_, &NotificationManager::on_notification_group_size_max_changed);
|
}
|
||||||
} else if (name == "online_cloud_timeout_ms") {
|
if (name == "language_pack_version") {
|
||||||
return send_closure(notification_manager_actor_, &NotificationManager::on_online_cloud_timeout_changed);
|
send_closure(language_pack_manager_, &LanguagePackManager::on_language_pack_version_changed, false, -1);
|
||||||
} else if (name == "notification_cloud_delay_ms") {
|
}
|
||||||
return send_closure(notification_manager_actor_, &NotificationManager::on_notification_cloud_delay_changed);
|
if (name == "localization_target") {
|
||||||
} else if (name == "notification_default_delay_ms") {
|
send_closure(language_pack_manager_, &LanguagePackManager::on_language_pack_changed);
|
||||||
return send_closure(notification_manager_actor_, &NotificationManager::on_notification_default_delay_changed);
|
if (G()->mtproto_header().set_language_pack(G()->shared_config().get_option_string(name))) {
|
||||||
} else if (name == "ignored_restriction_reasons") {
|
G()->net_query_dispatcher().update_mtproto_header();
|
||||||
return send_closure(contacts_manager_actor_, &ContactsManager::on_ignored_restriction_reasons_changed);
|
}
|
||||||
} else if (name == "dice_emojis") {
|
}
|
||||||
return send_closure(stickers_manager_actor_, &StickersManager::on_update_dice_emojis);
|
break;
|
||||||
} else if (name == "dice_success_values") {
|
case 'm':
|
||||||
return send_closure(stickers_manager_actor_, &StickersManager::on_update_dice_success_values);
|
if (name == "my_id") {
|
||||||
} else if (name == "emoji_sounds") {
|
G()->set_my_id(G()->shared_config().get_option_integer(name));
|
||||||
return send_closure(stickers_manager_actor_, &StickersManager::on_update_emoji_sounds);
|
}
|
||||||
} else if (is_internal_config_option(name)) {
|
break;
|
||||||
|
case 'n':
|
||||||
|
if (name == "notification_cloud_delay_ms") {
|
||||||
|
send_closure(notification_manager_actor_, &NotificationManager::on_notification_cloud_delay_changed);
|
||||||
|
}
|
||||||
|
if (name == "notification_default_delay_ms") {
|
||||||
|
send_closure(notification_manager_actor_, &NotificationManager::on_notification_default_delay_changed);
|
||||||
|
}
|
||||||
|
if (name == "notification_group_count_max") {
|
||||||
|
send_closure(notification_manager_actor_, &NotificationManager::on_notification_group_count_max_changed, true);
|
||||||
|
}
|
||||||
|
if (name == "notification_group_size_max") {
|
||||||
|
send_closure(notification_manager_actor_, &NotificationManager::on_notification_group_size_max_changed);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'o':
|
||||||
|
if (name == "online_cloud_timeout_ms") {
|
||||||
|
send_closure(notification_manager_actor_, &NotificationManager::on_online_cloud_timeout_changed);
|
||||||
|
}
|
||||||
|
if (name == "otherwise_relogin_days") {
|
||||||
|
auto days = narrow_cast<int32>(G()->shared_config().get_option_integer(name));
|
||||||
|
if (days > 0) {
|
||||||
|
vector<SuggestedAction> added_actions{SuggestedAction{SuggestedAction::Type::SetPassword, DialogId(), days}};
|
||||||
|
send_closure(G()->td(), &Td::send_update, get_update_suggested_actions_object(added_actions, {}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'r':
|
||||||
|
if (name == "rating_e_decay") {
|
||||||
|
send_closure(top_dialog_manager_actor_, &TopDialogManager::update_rating_e_decay);
|
||||||
|
}
|
||||||
|
if (name == "recent_stickers_limit") {
|
||||||
|
stickers_manager_->on_update_recent_stickers_limit(
|
||||||
|
narrow_cast<int32>(G()->shared_config().get_option_integer(name)));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
if (name == "saved_animations_limit") {
|
||||||
|
animations_manager_->on_update_saved_animations_limit(
|
||||||
|
narrow_cast<int32>(G()->shared_config().get_option_integer(name)));
|
||||||
|
}
|
||||||
|
if (name == "session_count") {
|
||||||
|
G()->net_query_dispatcher().update_session_count();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'u':
|
||||||
|
if (name == "use_pfs") {
|
||||||
|
G()->net_query_dispatcher().update_use_pfs();
|
||||||
|
}
|
||||||
|
if (name == "use_storage_optimizer") {
|
||||||
|
send_closure(storage_manager_, &StorageManager::update_use_storage_optimizer);
|
||||||
|
}
|
||||||
|
if (name == "utc_time_offset") {
|
||||||
|
if (G()->mtproto_header().set_tz_offset(static_cast<int32>(G()->shared_config().get_option_integer(name)))) {
|
||||||
|
G()->net_query_dispatcher().update_mtproto_header();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_internal_config_option(name)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7388,7 +7450,7 @@ void Td::on_request(uint64 id, td_api::setOption &request) {
|
|||||||
|
|
||||||
LOG(INFO) << "Set option " << request.name_;
|
LOG(INFO) << "Set option " << request.name_;
|
||||||
|
|
||||||
auto set_integer_option = [&](Slice name, int64 min = 0, int64 max = std::numeric_limits<int32>::max()) {
|
auto set_integer_option = [&](Slice name, int64 min_value = 0, int64 max_value = std::numeric_limits<int32>::max()) {
|
||||||
if (request.name_ != name) {
|
if (request.name_ != name) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -7401,13 +7463,13 @@ void Td::on_request(uint64 id, td_api::setOption &request) {
|
|||||||
G()->shared_config().set_option_empty(name);
|
G()->shared_config().set_option_empty(name);
|
||||||
} else {
|
} else {
|
||||||
int64 value = static_cast<td_api::optionValueInteger *>(request.value_.get())->value_;
|
int64 value = static_cast<td_api::optionValueInteger *>(request.value_.get())->value_;
|
||||||
if (value < min || value > max) {
|
if (value < min_value || value > max_value) {
|
||||||
send_error_raw(id, 400,
|
send_error_raw(id, 400,
|
||||||
PSLICE() << "Option's \"" << name << "\" value " << value << " is outside of a valid range ["
|
PSLICE() << "Option's \"" << name << "\" value " << value << " is outside of a valid range ["
|
||||||
<< min << ", " << max << "]");
|
<< min_value << ", " << max_value << "]");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
G()->shared_config().set_option_integer(name, clamp(value, min, max));
|
G()->shared_config().set_option_integer(name, clamp(value, min_value, max_value));
|
||||||
}
|
}
|
||||||
send_closure(actor_id(this), &Td::send_result, id, make_tl_object<td_api::ok>());
|
send_closure(actor_id(this), &Td::send_result, id, make_tl_object<td_api::ok>());
|
||||||
return true;
|
return true;
|
||||||
@ -7652,9 +7714,6 @@ void Td::on_request(uint64 id, td_api::setOption &request) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
if (set_integer_option("session_count", 0, 50)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (set_integer_option("storage_max_files_size")) {
|
if (set_integer_option("storage_max_files_size")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -134,18 +134,18 @@ uint64 Random::fast_uint64() {
|
|||||||
return static_cast<uint64>((*gen)());
|
return static_cast<uint64>((*gen)());
|
||||||
}
|
}
|
||||||
|
|
||||||
int Random::fast(int min, int max) {
|
int Random::fast(int min_value, int max_value) {
|
||||||
if (min == std::numeric_limits<int>::min() && max == std::numeric_limits<int>::max()) {
|
if (min_value == std::numeric_limits<int>::min() && max_value == std::numeric_limits<int>::max()) {
|
||||||
// to prevent integer overflow and division by zero
|
// to prevent integer overflow and division by zero
|
||||||
min++;
|
min_value++;
|
||||||
}
|
}
|
||||||
DCHECK(min <= max);
|
DCHECK(min_value <= max_value);
|
||||||
return static_cast<int>(min + fast_uint32() % (max - min + 1)); // TODO signed_cast
|
return static_cast<int>(min_value + fast_uint32() % (max_value - min_value + 1)); // TODO signed_cast
|
||||||
}
|
}
|
||||||
|
|
||||||
double Random::fast(double min, double max) {
|
double Random::fast(double min_value, double max_value) {
|
||||||
DCHECK(min <= max);
|
DCHECK(min_value <= max_value);
|
||||||
return min + fast_uint32() * 1.0 / std::numeric_limits<uint32>::max() * (max - min);
|
return min_value + fast_uint32() * 1.0 / std::numeric_limits<uint32>::max() * (max_value - min_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Random::fast_bool() {
|
bool Random::fast_bool() {
|
||||||
@ -179,11 +179,11 @@ uint64 Random::Xorshift128plus::operator()() {
|
|||||||
return seed_[1] + y;
|
return seed_[1] + y;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Random::Xorshift128plus::fast(int min, int max) {
|
int Random::Xorshift128plus::fast(int min_value, int max_value) {
|
||||||
return static_cast<int>((*this)() % (max - min + 1) + min);
|
return static_cast<int>((*this)() % (max_value - min_value + 1) + min_value);
|
||||||
}
|
}
|
||||||
int64 Random::Xorshift128plus::fast64(int64 min, int64 max) {
|
int64 Random::Xorshift128plus::fast64(int64 min_value, int64 max_value) {
|
||||||
return static_cast<int64>((*this)() % (max - min + 1) + min);
|
return static_cast<int64>((*this)() % (max_value - min_value + 1) + min_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Random::Xorshift128plus::bytes(MutableSlice dest) {
|
void Random::Xorshift128plus::bytes(MutableSlice dest) {
|
||||||
|
@ -32,9 +32,9 @@ class Random {
|
|||||||
static uint32 fast_uint32();
|
static uint32 fast_uint32();
|
||||||
static uint64 fast_uint64();
|
static uint64 fast_uint64();
|
||||||
|
|
||||||
// distribution is not uniform, min and max are included
|
// distribution is not uniform, min_value and max_value are included
|
||||||
static int fast(int min, int max);
|
static int fast(int min_value, int max_value);
|
||||||
static double fast(double min, double max);
|
static double fast(double min_value, double max_value);
|
||||||
static bool fast_bool();
|
static bool fast_bool();
|
||||||
|
|
||||||
class Fast {
|
class Fast {
|
||||||
@ -48,8 +48,8 @@ class Random {
|
|||||||
explicit Xorshift128plus(uint64 seed);
|
explicit Xorshift128plus(uint64 seed);
|
||||||
Xorshift128plus(uint64 seed_a, uint64 seed_b);
|
Xorshift128plus(uint64 seed_a, uint64 seed_b);
|
||||||
uint64 operator()();
|
uint64 operator()();
|
||||||
int fast(int min, int max);
|
int fast(int min_value, int max_value);
|
||||||
int64 fast64(int64 min, int64 max);
|
int64 fast64(int64 min_value, int64 max_value);
|
||||||
void bytes(MutableSlice dest);
|
void bytes(MutableSlice dest);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -790,10 +790,10 @@ const NativeFd &UdpSocketFd::get_native_fd() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if TD_PORT_POSIX
|
#if TD_PORT_POSIX
|
||||||
static Result<uint32> maximize_buffer(int socket_fd, int optname, uint32 max) {
|
static Result<uint32> maximize_buffer(int socket_fd, int optname, uint32 max_size) {
|
||||||
if (setsockopt(socket_fd, SOL_SOCKET, optname, &max, sizeof(max)) == 0) {
|
if (setsockopt(socket_fd, SOL_SOCKET, optname, &max_size, sizeof(max_size)) == 0) {
|
||||||
// fast path
|
// fast path
|
||||||
return max;
|
return max_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Start with the default size. */
|
/* Start with the default size. */
|
||||||
@ -807,32 +807,32 @@ static Result<uint32> maximize_buffer(int socket_fd, int optname, uint32 max) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Binary-search for the real maximum. */
|
/* Binary-search for the real maximum. */
|
||||||
uint32 last_good = old_size;
|
uint32 last_good_size = old_size;
|
||||||
uint32 min = old_size;
|
uint32 min_size = old_size;
|
||||||
while (min <= max) {
|
while (min_size <= max_size) {
|
||||||
uint32 avg = min + (max - min) / 2;
|
uint32 avg_size = min_size + (max_size - min_size) / 2;
|
||||||
if (setsockopt(socket_fd, SOL_SOCKET, optname, &avg, sizeof(avg)) == 0) {
|
if (setsockopt(socket_fd, SOL_SOCKET, optname, &avg_size, sizeof(avg_size)) == 0) {
|
||||||
last_good = avg;
|
last_good_size = avg_size;
|
||||||
min = avg + 1;
|
min_size = avg_size + 1;
|
||||||
} else {
|
} else {
|
||||||
max = avg - 1;
|
max_size = avg_size - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return last_good;
|
return last_good_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<uint32> UdpSocketFd::maximize_snd_buffer(uint32 max) {
|
Result<uint32> UdpSocketFd::maximize_snd_buffer(uint32 max_size) {
|
||||||
return maximize_buffer(get_native_fd().fd(), SO_SNDBUF, max == 0 ? DEFAULT_UDP_MAX_SND_BUFFER_SIZE : max);
|
return maximize_buffer(get_native_fd().fd(), SO_SNDBUF, max_size == 0 ? DEFAULT_UDP_MAX_SND_BUFFER_SIZE : max_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<uint32> UdpSocketFd::maximize_rcv_buffer(uint32 max) {
|
Result<uint32> UdpSocketFd::maximize_rcv_buffer(uint32 max_size) {
|
||||||
return maximize_buffer(get_native_fd().fd(), SO_RCVBUF, max == 0 ? DEFAULT_UDP_MAX_RCV_BUFFER_SIZE : max);
|
return maximize_buffer(get_native_fd().fd(), SO_RCVBUF, max_size == 0 ? DEFAULT_UDP_MAX_RCV_BUFFER_SIZE : max_size);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
Result<uint32> UdpSocketFd::maximize_snd_buffer(uint32 max) {
|
Result<uint32> UdpSocketFd::maximize_snd_buffer(uint32 max_size) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Result<uint32> UdpSocketFd::maximize_rcv_buffer(uint32 max) {
|
Result<uint32> UdpSocketFd::maximize_rcv_buffer(uint32 max_size) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -45,8 +45,8 @@ class UdpSocketFd {
|
|||||||
UdpSocketFd(const UdpSocketFd &) = delete;
|
UdpSocketFd(const UdpSocketFd &) = delete;
|
||||||
UdpSocketFd &operator=(const UdpSocketFd &) = delete;
|
UdpSocketFd &operator=(const UdpSocketFd &) = delete;
|
||||||
|
|
||||||
Result<uint32> maximize_snd_buffer(uint32 max_buffer_size = 0);
|
Result<uint32> maximize_snd_buffer(uint32 max_size = 0);
|
||||||
Result<uint32> maximize_rcv_buffer(uint32 max_buffer_size = 0);
|
Result<uint32> maximize_rcv_buffer(uint32 max_size = 0);
|
||||||
|
|
||||||
static Result<UdpSocketFd> open(const IPAddress &address) TD_WARN_UNUSED_RESULT;
|
static Result<UdpSocketFd> open(const IPAddress &address) TD_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user