Add getStoryNotificationSettingsExceptions.

This commit is contained in:
levlam 2023-07-06 19:15:00 +03:00
parent b1cb40b22f
commit 5c3bbc7bb9
6 changed files with 79 additions and 1 deletions

View File

@ -7226,7 +7226,7 @@ addSavedNotificationSound sound:InputFile = NotificationSound;
removeSavedNotificationSound notification_sound_id:int64 = Ok;
//@description Returns list of chats with non-default notification settings
//@description Returns list of chats with non-default notification settings for new messages
//@scope If specified, only chats from the scope will be returned; pass null to return chats from all scopes
//@compare_sound Pass true to include in the response chats with only non-default sound
getChatNotificationSettingsExceptions scope:NotificationSettingsScope compare_sound:Bool = Chats;
@ -7289,6 +7289,9 @@ loadActiveStories story_list:StoryList = Ok;
//@description Toggles whether stories posted by the chat are available above chat lists @chat_id Identifier of the chat that posted stories @are_hidden Pass true to make the stories unavailable above the chat lists; pass false to make them available
toggleChatStoriesAreHidden chat_id:int53 are_hidden:Bool = Ok;
//@description Returns list of chats with non-default notification settings for stories
getStoryNotificationSettingsExceptions = Chats;
//@description Returns the list of active stories posted by the given chat @chat_id Chat identifier
getChatActiveStories chat_id:int53 = ActiveStories;

View File

@ -283,6 +283,64 @@ class GetNotifySettingsExceptionsQuery final : public Td::ResultHandler {
}
};
class GetStoryNotifySettingsExceptionsQuery final : public Td::ResultHandler {
Promise<td_api::object_ptr<td_api::chats>> promise_;
public:
explicit GetStoryNotifySettingsExceptionsQuery(Promise<td_api::object_ptr<td_api::chats>> &&promise)
: promise_(std::move(promise)) {
}
void send() {
int32 flags = telegram_api::account_getNotifyExceptions::COMPARE_STORIES_MASK;
send_query(G()->net_query_creator().create(
telegram_api::account_getNotifyExceptions(flags, false /*ignored*/, false /*ignored*/, nullptr)));
}
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::account_getNotifyExceptions>(packet);
if (result_ptr.is_error()) {
return on_error(result_ptr.move_as_error());
}
auto updates_ptr = result_ptr.move_as_ok();
auto dialog_ids = UpdatesManager::get_update_notify_settings_dialog_ids(updates_ptr.get());
vector<tl_object_ptr<telegram_api::User>> users;
vector<tl_object_ptr<telegram_api::Chat>> chats;
switch (updates_ptr->get_id()) {
case telegram_api::updatesCombined::ID: {
auto updates = static_cast<telegram_api::updatesCombined *>(updates_ptr.get());
users = std::move(updates->users_);
chats = std::move(updates->chats_);
reset_to_empty(updates->users_);
reset_to_empty(updates->chats_);
break;
}
case telegram_api::updates::ID: {
auto updates = static_cast<telegram_api::updates *>(updates_ptr.get());
users = std::move(updates->users_);
chats = std::move(updates->chats_);
reset_to_empty(updates->users_);
reset_to_empty(updates->chats_);
break;
}
}
td_->contacts_manager_->on_get_users(std::move(users), "GetStoryNotifySettingsExceptionsQuery");
td_->contacts_manager_->on_get_chats(std::move(chats), "GetStoryNotifySettingsExceptionsQuery");
for (auto &dialog_id : dialog_ids) {
td_->messages_manager_->force_create_dialog(dialog_id, "GetStoryNotifySettingsExceptionsQuery");
}
auto chat_ids = td_->messages_manager_->get_chats_object(-1, dialog_ids, "GetStoryNotifySettingsExceptionsQuery");
auto promise = PromiseCreator::lambda([promise = std::move(promise_), chat_ids = std::move(chat_ids)](
Result<Unit>) mutable { promise.set_value(std::move(chat_ids)); });
td_->updates_manager_->on_get_updates(std::move(updates_ptr), std::move(promise));
}
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
class GetScopeNotifySettingsQuery final : public Td::ResultHandler {
Promise<Unit> promise_;
NotificationSettingsScope scope_;
@ -1455,6 +1513,11 @@ void NotificationSettingsManager::get_notify_settings_exceptions(NotificationSet
td_->create_handler<GetNotifySettingsExceptionsQuery>(std::move(promise))->send(scope, filter_scope, compare_sound);
}
void NotificationSettingsManager::get_story_notification_settings_exceptions(
Promise<td_api::object_ptr<td_api::chats>> &&promise) {
td_->create_handler<GetStoryNotifySettingsExceptionsQuery>(std::move(promise))->send();
}
void NotificationSettingsManager::on_binlog_events(vector<BinlogEvent> &&events) {
if (G()->close_flag()) {
return;

View File

@ -102,6 +102,8 @@ class NotificationSettingsManager final : public Actor {
void get_notify_settings_exceptions(NotificationSettingsScope scope, bool filter_scope, bool compare_sound,
Promise<Unit> &&promise);
void get_story_notification_settings_exceptions(Promise<td_api::object_ptr<td_api::chats>> &&promise);
void init();
void on_binlog_events(vector<BinlogEvent> &&events);

View File

@ -6429,6 +6429,12 @@ void Td::on_request(uint64 id, const td_api::readChatList &request) {
messages_manager_->read_all_dialogs_from_list(DialogListId(request.chat_list_), std::move(promise));
}
void Td::on_request(uint64 id, const td_api::getStoryNotificationSettingsExceptions &request) {
CHECK_IS_USER();
CREATE_REQUEST_PROMISE();
notification_settings_manager_->get_story_notification_settings_exceptions(std::move(promise));
}
void Td::on_request(uint64 id, const td_api::getChatActiveStories &request) {
CHECK_IS_USER();
CREATE_REQUEST_PROMISE();

View File

@ -1002,6 +1002,8 @@ class Td final : public Actor {
void on_request(uint64 id, const td_api::readChatList &request);
void on_request(uint64 id, const td_api::getStoryNotificationSettingsExceptions &request);
void on_request(uint64 id, const td_api::getChatActiveStories &request);
void on_request(uint64 id, const td_api::getChatPinnedStories &request);

View File

@ -4064,6 +4064,8 @@ class CliClient final : public Actor {
string limit;
get_args(args, from_story_id, limit);
send_request(td_api::make_object<td_api::getArchivedStories>(from_story_id, as_limit(limit)));
} else if (op == "gsnse") {
send_request(td_api::make_object<td_api::getStoryNotificationSettingsExceptions>());
} else if (op == "gcas") {
ChatId chat_id;
get_args(args, chat_id);