Compare local settings in getChatNotificationSettingsExceptions.
GitOrigin-RevId: e0ad2683e85f1a2d74206da01dfc9e60248e611d
This commit is contained in:
parent
0a04a466ef
commit
8fcb64e579
@ -2867,10 +2867,10 @@ class GetDialogNotifySettingsQuery : public Td::ResultHandler {
|
||||
};
|
||||
|
||||
class GetNotifySettingsExceptionsQuery : public Td::ResultHandler {
|
||||
Promise<vector<DialogId>> promise_;
|
||||
Promise<Unit> promise_;
|
||||
|
||||
public:
|
||||
explicit GetNotifySettingsExceptionsQuery(Promise<vector<DialogId>> &&promise) : promise_(std::move(promise)) {
|
||||
explicit GetNotifySettingsExceptionsQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send(NotificationSettingsScope scope, bool filter_scope, bool compare_sound) {
|
||||
@ -2922,7 +2922,7 @@ class GetNotifySettingsExceptionsQuery : public Td::ResultHandler {
|
||||
}
|
||||
td->updates_manager_->on_get_updates(std::move(updates_ptr));
|
||||
|
||||
promise_.set_value(std::move(dialog_ids));
|
||||
promise_.set_value(Unit());
|
||||
}
|
||||
|
||||
void on_error(uint64 id, Status status) override {
|
||||
@ -13150,10 +13150,37 @@ int32 MessagesManager::get_scope_mute_until(DialogId dialog_id) const {
|
||||
}
|
||||
}
|
||||
|
||||
void MessagesManager::get_dialog_notification_settings_exceptions(NotificationSettingsScope scope, bool filter_scope,
|
||||
bool compare_sound,
|
||||
Promise<vector<DialogId>> &&promise) {
|
||||
vector<DialogId> MessagesManager::get_dialog_notification_settings_exceptions(NotificationSettingsScope scope,
|
||||
bool filter_scope, bool compare_sound,
|
||||
bool force, Promise<Unit> &&promise) {
|
||||
if (last_dialog_date_ == MAX_DIALOG_DATE || force) {
|
||||
vector<DialogId> result;
|
||||
for (const auto &it : ordered_server_dialogs_) {
|
||||
auto dialog_id = it.get_dialog_id();
|
||||
if (filter_scope && get_dialog_notification_setting_scope(dialog_id) != scope) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Dialog *d = get_dialog(dialog_id);
|
||||
CHECK(d != nullptr);
|
||||
if (d->order == DEFAULT_ORDER) {
|
||||
break;
|
||||
}
|
||||
if (are_default_dialog_notification_settings(d->notification_settings, compare_sound)) {
|
||||
continue;
|
||||
}
|
||||
result.push_back(dialog_id);
|
||||
}
|
||||
promise.set_value(Unit());
|
||||
return result;
|
||||
}
|
||||
|
||||
if (ordered_dialogs_.size() < MAX_PRELOADED_DIALOGS) {
|
||||
preload_dialog_list(static_cast<void *>(this));
|
||||
}
|
||||
|
||||
td_->create_handler<GetNotifySettingsExceptionsQuery>(std::move(promise))->send(scope, filter_scope, compare_sound);
|
||||
return {};
|
||||
}
|
||||
|
||||
const ScopeNotificationSettings *MessagesManager::get_scope_notification_settings(NotificationSettingsScope scope,
|
||||
|
@ -528,8 +528,8 @@ class MessagesManager : public Actor {
|
||||
td_api::object_ptr<td_api::updateScopeNotificationSettings> get_update_scope_notification_settings_object(
|
||||
NotificationSettingsScope scope) const;
|
||||
|
||||
void get_dialog_notification_settings_exceptions(NotificationSettingsScope scope, bool filter_scope,
|
||||
bool compare_sound, Promise<vector<DialogId>> &&promise);
|
||||
vector<DialogId> get_dialog_notification_settings_exceptions(NotificationSettingsScope scope, bool filter_scope,
|
||||
bool compare_sound, bool force, Promise<Unit> &&promise);
|
||||
|
||||
const ScopeNotificationSettings *get_scope_notification_settings(NotificationSettingsScope scope,
|
||||
Promise<Unit> &&promise);
|
||||
|
@ -224,4 +224,10 @@ ScopeNotificationSettings get_scope_notification_settings(tl_object_ptr<telegram
|
||||
old_disable_mention_notifications};
|
||||
}
|
||||
|
||||
bool are_default_dialog_notification_settings(const DialogNotificationSettings &settings, bool compare_sound) {
|
||||
return settings.use_default_mute_until && (!compare_sound || settings.use_default_sound) &&
|
||||
settings.use_default_show_preview && settings.use_default_disable_pinned_message_notifications &&
|
||||
settings.use_default_disable_mention_notifications;
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
@ -118,4 +118,6 @@ ScopeNotificationSettings get_scope_notification_settings(tl_object_ptr<telegram
|
||||
bool old_disable_pinned_message_notifications,
|
||||
bool old_disable_mention_notifications);
|
||||
|
||||
bool are_default_dialog_notification_settings(const DialogNotificationSettings &settings, bool compare_sound);
|
||||
|
||||
} // namespace td
|
||||
|
@ -2088,24 +2088,16 @@ class GetUserProfilePhotosRequest : public RequestActor<> {
|
||||
}
|
||||
};
|
||||
|
||||
class GetChatNotificationSettingsExceptionsRequest : public RequestActor<vector<DialogId>> {
|
||||
class GetChatNotificationSettingsExceptionsRequest : public RequestActor<> {
|
||||
NotificationSettingsScope scope_;
|
||||
bool filter_scope_;
|
||||
bool compare_sound_;
|
||||
|
||||
vector<DialogId> dialog_ids_;
|
||||
|
||||
void do_run(Promise<vector<DialogId>> &&promise) override {
|
||||
if (get_tries() < 2) {
|
||||
promise.set_value(std::move(dialog_ids_));
|
||||
return;
|
||||
}
|
||||
td->messages_manager_->get_dialog_notification_settings_exceptions(scope_, filter_scope_, compare_sound_,
|
||||
std::move(promise));
|
||||
}
|
||||
|
||||
void do_set_result(vector<DialogId> &&result) override {
|
||||
dialog_ids_ = std::move(result);
|
||||
void do_run(Promise<Unit> &&promise) override {
|
||||
dialog_ids_ = td->messages_manager_->get_dialog_notification_settings_exceptions(
|
||||
scope_, filter_scope_, compare_sound_, get_tries() < 3, std::move(promise));
|
||||
}
|
||||
|
||||
void do_send_result() override {
|
||||
@ -2119,6 +2111,7 @@ class GetChatNotificationSettingsExceptionsRequest : public RequestActor<vector<
|
||||
, scope_(scope)
|
||||
, filter_scope_(filter_scope)
|
||||
, compare_sound_(compare_sound) {
|
||||
set_tries(3);
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user