Add td_api::updateReactionNotificationSettings.
This commit is contained in:
parent
8246f955c9
commit
0dda4a53f3
@ -6979,6 +6979,9 @@ updateForumTopicInfo chat_id:int53 info:forumTopicInfo = Update;
|
||||
//@description Notification settings for some type of chats were updated @scope Types of chats for which notification settings were updated @notification_settings The new notification settings
|
||||
updateScopeNotificationSettings scope:NotificationSettingsScope notification_settings:scopeNotificationSettings = Update;
|
||||
|
||||
//@description Notification settings for reactions were updated @notification_settings The new notification settings
|
||||
updateReactionNotificationSettings notification_settings:reactionNotificationSettings = Update;
|
||||
|
||||
//@description A notification was changed @notification_group_id Unique notification group identifier @notification Changed notification
|
||||
updateNotification notification_group_id:int32 notification:notification = Update;
|
||||
|
||||
|
@ -375,6 +375,34 @@ class GetScopeNotifySettingsQuery final : public Td::ResultHandler {
|
||||
}
|
||||
};
|
||||
|
||||
class GetReactionsNotifySettingsQuery final : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
|
||||
public:
|
||||
explicit GetReactionsNotifySettingsQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send() {
|
||||
send_query(G()->net_query_creator().create(telegram_api::account_getReactionsNotifySettings()));
|
||||
}
|
||||
|
||||
void on_result(BufferSlice packet) final {
|
||||
auto result_ptr = fetch_result<telegram_api::account_getReactionsNotifySettings>(packet);
|
||||
if (result_ptr.is_error()) {
|
||||
return on_error(result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
auto ptr = result_ptr.move_as_ok();
|
||||
td_->notification_settings_manager_->on_update_reaction_notification_settings(
|
||||
ReactionNotificationSettings(std::move(ptr)));
|
||||
promise_.set_value(Unit());
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
promise_.set_error(std::move(status));
|
||||
}
|
||||
};
|
||||
|
||||
class UpdateDialogNotifySettingsQuery final : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
DialogId dialog_id_;
|
||||
@ -717,6 +745,12 @@ NotificationSettingsManager::get_update_scope_notification_settings_object(Notif
|
||||
get_notification_settings_scope_object(scope), get_scope_notification_settings_object(notification_settings));
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::updateReactionNotificationSettings>
|
||||
NotificationSettingsManager::get_update_reaction_notification_settings_object() const {
|
||||
return td_api::make_object<td_api::updateReactionNotificationSettings>(
|
||||
reaction_notification_settings_.get_reaction_notification_settings_object());
|
||||
}
|
||||
|
||||
void NotificationSettingsManager::on_scope_unmute(NotificationSettingsScope scope) {
|
||||
if (td_->auth_manager_->is_bot()) {
|
||||
// just in case
|
||||
@ -826,6 +860,30 @@ bool NotificationSettingsManager::update_scope_notification_settings(Notificatio
|
||||
return need_update_server;
|
||||
}
|
||||
|
||||
void NotificationSettingsManager::send_get_reaction_notification_settings_query(Promise<Unit> &&promise) {
|
||||
if (td_->auth_manager_->is_bot()) {
|
||||
LOG(ERROR) << "Can't get reaction notification settings";
|
||||
return promise.set_error(Status::Error(500, "Wrong getReactionNotificationSettings query"));
|
||||
}
|
||||
|
||||
td_->create_handler<GetReactionsNotifySettingsQuery>(std::move(promise))->send();
|
||||
}
|
||||
|
||||
void NotificationSettingsManager::on_update_reaction_notification_settings(
|
||||
ReactionNotificationSettings reaction_notification_settings) {
|
||||
CHECK(!td_->auth_manager_->is_bot());
|
||||
if (reaction_notification_settings == reaction_notification_settings_) {
|
||||
return;
|
||||
}
|
||||
|
||||
VLOG(notifications) << "Update reaction notification settings from " << reaction_notification_settings_ << " to "
|
||||
<< reaction_notification_settings;
|
||||
|
||||
reaction_notification_settings_ = std::move(reaction_notification_settings);
|
||||
|
||||
send_closure(G()->td(), &Td::send_update, get_update_reaction_notification_settings_object());
|
||||
}
|
||||
|
||||
void NotificationSettingsManager::schedule_scope_unmute(NotificationSettingsScope scope, int32 mute_until,
|
||||
int32 unix_time) {
|
||||
if (mute_until >= unix_time && mute_until < unix_time + 366 * 86400) {
|
||||
@ -1566,6 +1624,8 @@ void NotificationSettingsManager::get_current_state(vector<td_api::object_ptr<td
|
||||
}
|
||||
}
|
||||
|
||||
updates.push_back(get_update_reaction_notification_settings_object());
|
||||
|
||||
if (are_saved_ringtones_loaded_) {
|
||||
updates.push_back(get_update_saved_notification_sounds_object());
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "td/telegram/MessageFullId.h"
|
||||
#include "td/telegram/MessageId.h"
|
||||
#include "td/telegram/NotificationSettingsScope.h"
|
||||
#include "td/telegram/ReactionNotificationSettings.h"
|
||||
#include "td/telegram/ScopeNotificationSettings.h"
|
||||
#include "td/telegram/td_api.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
@ -67,6 +68,8 @@ class NotificationSettingsManager final : public Actor {
|
||||
void on_update_scope_notify_settings(NotificationSettingsScope scope,
|
||||
tl_object_ptr<telegram_api::peerNotifySettings> &&peer_notify_settings);
|
||||
|
||||
void on_update_reaction_notification_settings(ReactionNotificationSettings reaction_notification_settings);
|
||||
|
||||
void add_saved_ringtone(td_api::object_ptr<td_api::InputFile> &&input_file,
|
||||
Promise<td_api::object_ptr<td_api::notificationSound>> &&promise);
|
||||
|
||||
@ -92,6 +95,8 @@ class NotificationSettingsManager final : public Actor {
|
||||
Promise<Unit> &&promise);
|
||||
void send_get_scope_notification_settings_query(NotificationSettingsScope scope, Promise<Unit> &&promise);
|
||||
|
||||
void send_get_reaction_notification_settings_query(Promise<Unit> &&promise);
|
||||
|
||||
void on_get_dialog_notification_settings_query_finished(DialogId dialog_id, MessageId top_thread_message_id,
|
||||
Status &&status);
|
||||
|
||||
@ -172,6 +177,9 @@ class NotificationSettingsManager final : public Actor {
|
||||
td_api::object_ptr<td_api::updateScopeNotificationSettings> get_update_scope_notification_settings_object(
|
||||
NotificationSettingsScope scope) const;
|
||||
|
||||
td_api::object_ptr<td_api::updateReactionNotificationSettings> get_update_reaction_notification_settings_object()
|
||||
const;
|
||||
|
||||
td_api::object_ptr<td_api::updateSavedNotificationSounds> get_update_saved_notification_sounds_object() const;
|
||||
|
||||
void on_scope_unmute(NotificationSettingsScope scope);
|
||||
@ -203,6 +211,8 @@ class NotificationSettingsManager final : public Actor {
|
||||
ScopeNotificationSettings chats_notification_settings_;
|
||||
ScopeNotificationSettings channels_notification_settings_;
|
||||
|
||||
ReactionNotificationSettings reaction_notification_settings_;
|
||||
|
||||
MultiTimeout scope_unmute_timeout_{"ScopeUnmuteTimeout"};
|
||||
|
||||
int64 saved_ringtone_hash_ = 0;
|
||||
|
@ -2252,6 +2252,7 @@ void UpdatesManager::try_reload_data() {
|
||||
get_default_emoji_statuses(td_, Auto());
|
||||
get_default_channel_emoji_statuses(td_, Auto());
|
||||
td_->notification_settings_manager_->reload_saved_ringtones(Auto());
|
||||
td_->notification_settings_manager_->send_get_reaction_notification_settings_query(Auto());
|
||||
td_->notification_settings_manager_->send_get_scope_notification_settings_query(NotificationSettingsScope::Private,
|
||||
Auto());
|
||||
td_->notification_settings_manager_->send_get_scope_notification_settings_query(NotificationSettingsScope::Group,
|
||||
|
Loading…
Reference in New Issue
Block a user