Add setForumTopicNotificationSettings.
This commit is contained in:
parent
c654041d9b
commit
d9e16106af
@ -1005,12 +1005,12 @@ notificationSettingsScopeGroupChats = NotificationSettingsScope;
|
||||
notificationSettingsScopeChannelChats = NotificationSettingsScope;
|
||||
|
||||
|
||||
//@description Contains information about notification settings for a chat
|
||||
//@use_default_mute_for If true, mute_for is ignored and the value for the relevant type of chat is used instead @mute_for Time left before notifications will be unmuted, in seconds
|
||||
//@use_default_sound If true, the value for the relevant type of chat is used instead of sound_id @sound_id Identifier of the notification sound to be played; 0 if sound is disabled
|
||||
//@use_default_show_preview If true, show_preview is ignored and the value for the relevant type of chat is used instead @show_preview True, if message content must be displayed in notifications
|
||||
//@use_default_disable_pinned_message_notifications If true, disable_pinned_message_notifications is ignored and the value for the relevant type of chat is used instead @disable_pinned_message_notifications If true, notifications for incoming pinned messages will be created as for an ordinary unread message
|
||||
//@use_default_disable_mention_notifications If true, disable_mention_notifications is ignored and the value for the relevant type of chat is used instead @disable_mention_notifications If true, notifications for messages with mentions will be created as for an ordinary unread message
|
||||
//@description Contains information about notification settings for a chat or a froum topic
|
||||
//@use_default_mute_for If true, mute_for is ignored and the value for the relevant type of chat or the forum chat is used instead @mute_for Time left before notifications will be unmuted, in seconds
|
||||
//@use_default_sound If true, the value for the relevant type of chat or the forum chat is used instead of sound_id @sound_id Identifier of the notification sound to be played; 0 if sound is disabled
|
||||
//@use_default_show_preview If true, show_preview is ignored and the value for the relevant type of chat or the forum chat is used instead @show_preview True, if message content must be displayed in notifications
|
||||
//@use_default_disable_pinned_message_notifications If true, disable_pinned_message_notifications is ignored and the value for the relevant type of chat or the forum chat is used instead @disable_pinned_message_notifications If true, notifications for incoming pinned messages will be created as for an ordinary unread message
|
||||
//@use_default_disable_mention_notifications If true, disable_mention_notifications is ignored and the value for the relevant type of chat or the forum chat is used instead @disable_mention_notifications If true, notifications for messages with mentions will be created as for an ordinary unread message
|
||||
chatNotificationSettings use_default_mute_for:Bool mute_for:int32 use_default_sound:Bool sound_id:int64 use_default_show_preview:Bool show_preview:Bool use_default_disable_pinned_message_notifications:Bool disable_pinned_message_notifications:Bool use_default_disable_mention_notifications:Bool disable_mention_notifications:Bool = ChatNotificationSettings;
|
||||
|
||||
//@description Contains information about notification settings for several chats
|
||||
@ -5346,6 +5346,10 @@ getForumTopic chat_id:int53 message_thread_id:int53 = ForumTopic;
|
||||
//@description Returns an HTTPS link to a topic in a forum chat. This is an offline request @chat_id Identifier of the chat @message_thread_id Message thread identifier of the forum topic
|
||||
getForumTopicLink chat_id:int53 message_thread_id:int53 = HttpUrl;
|
||||
|
||||
//@description Changes the notification settings of a forum topic
|
||||
//@chat_id Chat identifier @message_thread_id Message thread identifier of the forum topic @notification_settings New notification settings for the forum topic. If the topic is muted for more than 366 days, it is considered to be muted forever
|
||||
setForumTopicNotificationSettings chat_id:int53 message_thread_id:int53 notification_settings:chatNotificationSettings = Ok;
|
||||
|
||||
//@description Toggles whether a topic is closed in a forum supergroup chat; requires can_manage_topics administrator rights in the supergroup unless the user is creator of the topic
|
||||
//@chat_id Identifier of the chat
|
||||
//@message_thread_id Message thread identifier of the forum topic
|
||||
|
@ -40,6 +40,14 @@ class ForumTopic {
|
||||
return is_short_;
|
||||
}
|
||||
|
||||
DialogNotificationSettings *get_notification_settings() {
|
||||
return ¬ification_settings_;
|
||||
}
|
||||
|
||||
const DialogNotificationSettings *get_notification_settings() const {
|
||||
return ¬ification_settings_;
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::forumTopic> get_forum_topic_object(Td *td, DialogId dialog_id,
|
||||
const ForumTopicInfo &info) const;
|
||||
|
||||
|
@ -19,6 +19,8 @@
|
||||
#include "td/telegram/MessagesManager.h"
|
||||
#include "td/telegram/MessageThreadDb.h"
|
||||
#include "td/telegram/misc.h"
|
||||
#include "td/telegram/NotificationManager.h"
|
||||
#include "td/telegram/NotificationSettingsManager.h"
|
||||
#include "td/telegram/OptionManager.h"
|
||||
#include "td/telegram/ServerMessageId.h"
|
||||
#include "td/telegram/Td.h"
|
||||
@ -374,6 +376,115 @@ void ForumTopicManager::edit_forum_topic(DialogId dialog_id, MessageId top_threa
|
||||
->send(channel_id, top_thread_message_id, edit_title, new_title, edit_icon_custom_emoji, icon_custom_emoji_id);
|
||||
}
|
||||
|
||||
DialogNotificationSettings *ForumTopicManager::get_forum_topic_notification_settings(DialogId dialog_id,
|
||||
MessageId top_thread_message_id) {
|
||||
auto topic = get_topic(dialog_id, top_thread_message_id);
|
||||
if (topic == nullptr || topic->topic_ == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return topic->topic_->get_notification_settings();
|
||||
}
|
||||
|
||||
const DialogNotificationSettings *ForumTopicManager::get_forum_topic_notification_settings(
|
||||
DialogId dialog_id, MessageId top_thread_message_id) const {
|
||||
auto topic = get_topic(dialog_id, top_thread_message_id);
|
||||
if (topic == nullptr || topic->topic_ == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return topic->topic_->get_notification_settings();
|
||||
}
|
||||
|
||||
void ForumTopicManager::on_update_forum_topic_notify_settings(
|
||||
DialogId dialog_id, MessageId top_thread_message_id,
|
||||
tl_object_ptr<telegram_api::peerNotifySettings> &&peer_notify_settings, const char *source) {
|
||||
if (td_->auth_manager_->is_bot()) {
|
||||
return;
|
||||
}
|
||||
|
||||
VLOG(notifications) << "Receive notification settings for topic of " << top_thread_message_id << " in " << dialog_id
|
||||
<< " from " << source << ": " << to_string(peer_notify_settings);
|
||||
|
||||
DialogNotificationSettings *current_settings =
|
||||
get_forum_topic_notification_settings(dialog_id, top_thread_message_id);
|
||||
if (current_settings == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto notification_settings = get_dialog_notification_settings(
|
||||
std::move(peer_notify_settings), current_settings->use_default_disable_pinned_message_notifications,
|
||||
current_settings->disable_pinned_message_notifications,
|
||||
current_settings->use_default_disable_mention_notifications, current_settings->disable_mention_notifications);
|
||||
if (!notification_settings.is_synchronized) {
|
||||
return;
|
||||
}
|
||||
|
||||
update_forum_topic_notification_settings(dialog_id, top_thread_message_id, current_settings,
|
||||
std::move(notification_settings));
|
||||
}
|
||||
|
||||
Status ForumTopicManager::set_forum_topic_notification_settings(
|
||||
DialogId dialog_id, MessageId top_thread_message_id,
|
||||
tl_object_ptr<td_api::chatNotificationSettings> &¬ification_settings) {
|
||||
CHECK(!td_->auth_manager_->is_bot());
|
||||
TRY_STATUS(is_forum(dialog_id));
|
||||
TRY_STATUS(can_be_message_thread_id(top_thread_message_id));
|
||||
auto current_settings = get_forum_topic_notification_settings(dialog_id, top_thread_message_id);
|
||||
if (current_settings == nullptr) {
|
||||
return Status::Error(400, "Unknown forum topic identifier specified");
|
||||
}
|
||||
|
||||
TRY_RESULT(new_settings,
|
||||
get_dialog_notification_settings(std::move(notification_settings), current_settings->silent_send_message));
|
||||
if (is_notification_sound_default(current_settings->sound) && is_notification_sound_default(new_settings.sound)) {
|
||||
new_settings.sound = dup_notification_sound(current_settings->sound);
|
||||
}
|
||||
if (update_forum_topic_notification_settings(dialog_id, top_thread_message_id, current_settings,
|
||||
std::move(new_settings))) {
|
||||
// TODO log event
|
||||
td_->notification_settings_manager_->update_dialog_notify_settings(dialog_id, top_thread_message_id,
|
||||
*current_settings, Promise<Unit>());
|
||||
}
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
bool ForumTopicManager::update_forum_topic_notification_settings(DialogId dialog_id, MessageId top_thread_message_id,
|
||||
DialogNotificationSettings *current_settings,
|
||||
DialogNotificationSettings &&new_settings) {
|
||||
if (td_->auth_manager_->is_bot()) {
|
||||
// just in case
|
||||
return false;
|
||||
}
|
||||
|
||||
bool need_update_server = current_settings->mute_until != new_settings.mute_until ||
|
||||
!are_equivalent_notification_sounds(current_settings->sound, new_settings.sound) ||
|
||||
current_settings->show_preview != new_settings.show_preview ||
|
||||
current_settings->use_default_mute_until != new_settings.use_default_mute_until ||
|
||||
current_settings->use_default_show_preview != new_settings.use_default_show_preview;
|
||||
bool need_update_local =
|
||||
current_settings->use_default_disable_pinned_message_notifications !=
|
||||
new_settings.use_default_disable_pinned_message_notifications ||
|
||||
current_settings->disable_pinned_message_notifications != new_settings.disable_pinned_message_notifications ||
|
||||
current_settings->use_default_disable_mention_notifications !=
|
||||
new_settings.use_default_disable_mention_notifications ||
|
||||
current_settings->disable_mention_notifications != new_settings.disable_mention_notifications;
|
||||
|
||||
bool is_changed = need_update_server || need_update_local ||
|
||||
current_settings->is_synchronized != new_settings.is_synchronized ||
|
||||
current_settings->is_use_default_fixed != new_settings.is_use_default_fixed ||
|
||||
are_different_equivalent_notification_sounds(current_settings->sound, new_settings.sound);
|
||||
|
||||
if (is_changed) {
|
||||
// TODO update unmute timeouts, td_api updates, remove notifications
|
||||
*current_settings = std::move(new_settings);
|
||||
|
||||
auto topic = get_topic(dialog_id, top_thread_message_id);
|
||||
CHECK(topic != nullptr);
|
||||
topic->need_save_to_database_ = true;
|
||||
save_topic_to_database(dialog_id, topic);
|
||||
}
|
||||
return need_update_server;
|
||||
}
|
||||
|
||||
void ForumTopicManager::get_forum_topic(DialogId dialog_id, MessageId top_thread_message_id,
|
||||
Promise<td_api::object_ptr<td_api::forumTopic>> &&promise) {
|
||||
TRY_STATUS_PROMISE(promise, is_forum(dialog_id));
|
||||
|
@ -52,12 +52,23 @@ class ForumTopicManager final : public Actor {
|
||||
void toggle_forum_topic_is_closed(DialogId dialog_id, MessageId top_thread_message_id, bool is_closed,
|
||||
Promise<Unit> &&promise);
|
||||
|
||||
const DialogNotificationSettings *get_forum_topic_notification_settings(DialogId dialog_id,
|
||||
MessageId top_thread_message_id) const;
|
||||
|
||||
Status set_forum_topic_notification_settings(DialogId dialog_id, MessageId top_thread_message_id,
|
||||
tl_object_ptr<td_api::chatNotificationSettings> &¬ification_settings)
|
||||
TD_WARN_UNUSED_RESULT;
|
||||
|
||||
void toggle_forum_topic_is_hidden(DialogId dialog_id, bool is_hidden, Promise<Unit> &&promise);
|
||||
|
||||
void delete_forum_topic(DialogId dialog_id, MessageId top_thread_message_id, Promise<Unit> &&promise);
|
||||
|
||||
void delete_all_dialog_topics(DialogId dialog_id);
|
||||
|
||||
void on_update_forum_topic_notify_settings(DialogId dialog_id, MessageId top_thread_message_id,
|
||||
tl_object_ptr<telegram_api::peerNotifySettings> &&peer_notify_settings,
|
||||
const char *source);
|
||||
|
||||
void on_forum_topic_edited(DialogId dialog_id, MessageId top_thread_message_id,
|
||||
const ForumTopicEditedData &edited_data);
|
||||
|
||||
@ -119,6 +130,13 @@ class ForumTopicManager final : public Actor {
|
||||
|
||||
void set_topic_info(DialogId dialog_id, Topic *topic, unique_ptr<ForumTopicInfo> forum_topic_info);
|
||||
|
||||
DialogNotificationSettings *get_forum_topic_notification_settings(DialogId dialog_id,
|
||||
MessageId top_thread_message_id);
|
||||
|
||||
bool update_forum_topic_notification_settings(DialogId dialog_id, MessageId top_thread_message_id,
|
||||
DialogNotificationSettings *current_settings,
|
||||
DialogNotificationSettings &&new_settings);
|
||||
|
||||
void on_delete_forum_topic(DialogId dialog_id, MessageId top_thread_message_id, Promise<Unit> &&promise);
|
||||
|
||||
td_api::object_ptr<td_api::updateForumTopicInfo> get_update_forum_topic_info(DialogId dialog_id,
|
||||
|
@ -21043,7 +21043,7 @@ void MessagesManager::update_dialog_notification_settings_on_server(DialogId dia
|
||||
return;
|
||||
}
|
||||
|
||||
if (!from_binlog && td_->notification_settings_manager_->get_input_notify_peer(dialog_id) == nullptr) {
|
||||
if (!from_binlog && td_->notification_settings_manager_->get_input_notify_peer(dialog_id, MessageId()) == nullptr) {
|
||||
// don't even create new binlog events
|
||||
return;
|
||||
}
|
||||
@ -21077,8 +21077,8 @@ void MessagesManager::send_update_dialog_notification_settings_query(const Dialo
|
||||
CHECK(!td_->auth_manager_->is_bot());
|
||||
CHECK(d != nullptr);
|
||||
// TODO do not send two queries simultaneously or use InvokeAfter
|
||||
td_->notification_settings_manager_->update_dialog_notify_settings(d->dialog_id, d->notification_settings,
|
||||
std::move(promise));
|
||||
td_->notification_settings_manager_->update_dialog_notify_settings(d->dialog_id, MessageId(),
|
||||
d->notification_settings, std::move(promise));
|
||||
}
|
||||
|
||||
void MessagesManager::on_updated_dialog_notification_settings(DialogId dialog_id, uint64 generation) {
|
||||
@ -31210,8 +31210,8 @@ bool MessagesManager::add_new_message_notification(Dialog *d, Message *m, bool f
|
||||
settings_dialog = get_dialog(settings_dialog_id);
|
||||
}
|
||||
if (settings_dialog != nullptr) {
|
||||
td_->notification_settings_manager_->send_get_dialog_notification_settings_query(settings_dialog_id,
|
||||
std::move(promise));
|
||||
td_->notification_settings_manager_->send_get_dialog_notification_settings_query(
|
||||
settings_dialog_id, MessageId() /* TODO */, std::move(promise));
|
||||
} else {
|
||||
send_get_dialog_query(settings_dialog_id, std::move(promise), 0, "add_new_message_notification");
|
||||
}
|
||||
@ -37572,7 +37572,8 @@ void MessagesManager::fix_new_dialog(Dialog *d, unique_ptr<Message> &&last_datab
|
||||
d->notification_settings.is_use_default_fixed = true;
|
||||
on_dialog_updated(dialog_id, "reget notification settings");
|
||||
} else {
|
||||
td_->notification_settings_manager_->send_get_dialog_notification_settings_query(dialog_id, Promise<Unit>());
|
||||
td_->notification_settings_manager_->send_get_dialog_notification_settings_query(dialog_id, MessageId(),
|
||||
Promise<Unit>());
|
||||
}
|
||||
}
|
||||
if (td_->auth_manager_->is_bot() || d->notification_settings.use_default_mute_until ||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "td/telegram/files/FileLocation.h"
|
||||
#include "td/telegram/files/FileManager.h"
|
||||
#include "td/telegram/files/FileType.h"
|
||||
#include "td/telegram/ForumTopicManager.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/logevent/LogEvent.h"
|
||||
#include "td/telegram/logevent/LogEventHelper.h"
|
||||
@ -183,11 +184,14 @@ class GetSavedRingtonesQuery final : public Td::ResultHandler {
|
||||
|
||||
class GetDialogNotifySettingsQuery final : public Td::ResultHandler {
|
||||
DialogId dialog_id_;
|
||||
MessageId top_thread_message_id_;
|
||||
|
||||
public:
|
||||
void send(DialogId dialog_id) {
|
||||
void send(DialogId dialog_id, MessageId top_thread_message_id) {
|
||||
dialog_id_ = dialog_id;
|
||||
auto input_notify_peer = td_->notification_settings_manager_->get_input_notify_peer(dialog_id);
|
||||
top_thread_message_id_ = top_thread_message_id;
|
||||
auto input_notify_peer =
|
||||
td_->notification_settings_manager_->get_input_notify_peer(dialog_id, top_thread_message_id);
|
||||
CHECK(input_notify_peer != nullptr);
|
||||
send_query(G()->net_query_creator().create(telegram_api::account_getNotifySettings(std::move(input_notify_peer))));
|
||||
}
|
||||
@ -199,15 +203,21 @@ class GetDialogNotifySettingsQuery final : public Td::ResultHandler {
|
||||
}
|
||||
|
||||
auto ptr = result_ptr.move_as_ok();
|
||||
td_->messages_manager_->on_update_dialog_notify_settings(dialog_id_, std::move(ptr),
|
||||
"GetDialogNotifySettingsQuery");
|
||||
td_->notification_settings_manager_->on_get_dialog_notification_settings_query_finished(dialog_id_, Status::OK());
|
||||
if (top_thread_message_id_.is_valid()) {
|
||||
td_->forum_topic_manager_->on_update_forum_topic_notify_settings(dialog_id_, top_thread_message_id_,
|
||||
std::move(ptr), "GetDialogNotifySettingsQuery");
|
||||
} else {
|
||||
td_->messages_manager_->on_update_dialog_notify_settings(dialog_id_, std::move(ptr),
|
||||
"GetDialogNotifySettingsQuery");
|
||||
}
|
||||
td_->notification_settings_manager_->on_get_dialog_notification_settings_query_finished(
|
||||
dialog_id_, top_thread_message_id_, Status::OK());
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetDialogNotifySettingsQuery");
|
||||
td_->notification_settings_manager_->on_get_dialog_notification_settings_query_finished(dialog_id_,
|
||||
std::move(status));
|
||||
td_->notification_settings_manager_->on_get_dialog_notification_settings_query_finished(
|
||||
dialog_id_, top_thread_message_id_, std::move(status));
|
||||
}
|
||||
};
|
||||
|
||||
@ -308,15 +318,18 @@ class GetScopeNotifySettingsQuery final : public Td::ResultHandler {
|
||||
class UpdateDialogNotifySettingsQuery final : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
DialogId dialog_id_;
|
||||
MessageId top_thread_message_id_;
|
||||
|
||||
public:
|
||||
explicit UpdateDialogNotifySettingsQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send(DialogId dialog_id, const DialogNotificationSettings &new_settings) {
|
||||
void send(DialogId dialog_id, MessageId top_thread_message_id, const DialogNotificationSettings &new_settings) {
|
||||
dialog_id_ = dialog_id;
|
||||
top_thread_message_id_ = top_thread_message_id;
|
||||
|
||||
auto input_notify_peer = td_->notification_settings_manager_->get_input_notify_peer(dialog_id);
|
||||
auto input_notify_peer =
|
||||
td_->notification_settings_manager_->get_input_notify_peer(dialog_id, top_thread_message_id);
|
||||
if (input_notify_peer == nullptr) {
|
||||
return on_error(Status::Error(500, "Can't update chat notification settings"));
|
||||
}
|
||||
@ -360,9 +373,10 @@ class UpdateDialogNotifySettingsQuery final : public Td::ResultHandler {
|
||||
}
|
||||
|
||||
if (!td_->auth_manager_->is_bot() &&
|
||||
td_->notification_settings_manager_->get_input_notify_peer(dialog_id_) != nullptr) {
|
||||
td_->notification_settings_manager_->get_input_notify_peer(dialog_id_, top_thread_message_id_) != nullptr) {
|
||||
// trying to repair notification settings for this dialog
|
||||
td_->notification_settings_manager_->send_get_dialog_notification_settings_query(dialog_id_, Promise<>());
|
||||
td_->notification_settings_manager_->send_get_dialog_notification_settings_query(
|
||||
dialog_id_, top_thread_message_id_, Promise<>());
|
||||
}
|
||||
|
||||
promise_.set_error(std::move(status));
|
||||
@ -596,7 +610,7 @@ bool NotificationSettingsManager::get_scope_disable_mention_notifications(Notifi
|
||||
}
|
||||
|
||||
tl_object_ptr<telegram_api::InputNotifyPeer> NotificationSettingsManager::get_input_notify_peer(
|
||||
DialogId dialog_id) const {
|
||||
DialogId dialog_id, MessageId top_thread_message_id) const {
|
||||
if (!td_->messages_manager_->have_dialog(dialog_id)) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -604,6 +618,11 @@ tl_object_ptr<telegram_api::InputNotifyPeer> NotificationSettingsManager::get_in
|
||||
if (input_peer == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
if (top_thread_message_id.is_valid()) {
|
||||
CHECK(top_thread_message_id.is_server());
|
||||
return telegram_api::make_object<telegram_api::inputNotifyForumTopic>(
|
||||
std::move(input_peer), top_thread_message_id.get_server_message_id().get());
|
||||
}
|
||||
return make_tl_object<telegram_api::inputNotifyPeer>(std::move(input_peer));
|
||||
}
|
||||
|
||||
@ -1339,6 +1358,7 @@ FileSourceId NotificationSettingsManager::get_saved_ringtones_file_source_id() {
|
||||
}
|
||||
|
||||
void NotificationSettingsManager::send_get_dialog_notification_settings_query(DialogId dialog_id,
|
||||
MessageId top_thread_message_id,
|
||||
Promise<Unit> &&promise) {
|
||||
if (td_->auth_manager_->is_bot() || dialog_id.get_type() == DialogType::SecretChat) {
|
||||
LOG(WARNING) << "Can't get notification settings for " << dialog_id;
|
||||
@ -1349,14 +1369,14 @@ void NotificationSettingsManager::send_get_dialog_notification_settings_query(Di
|
||||
return promise.set_error(Status::Error(400, "Can't access the chat"));
|
||||
}
|
||||
|
||||
auto &promises = get_dialog_notification_settings_queries_[dialog_id];
|
||||
auto &promises = get_dialog_notification_settings_queries_[{dialog_id, top_thread_message_id}];
|
||||
promises.push_back(std::move(promise));
|
||||
if (promises.size() != 1) {
|
||||
// query has already been sent, just wait for the result
|
||||
return;
|
||||
}
|
||||
|
||||
td_->create_handler<GetDialogNotifySettingsQuery>()->send(dialog_id);
|
||||
td_->create_handler<GetDialogNotifySettingsQuery>()->send(dialog_id, top_thread_message_id);
|
||||
}
|
||||
|
||||
const ScopeNotificationSettings *NotificationSettingsManager::get_scope_notification_settings(
|
||||
@ -1383,9 +1403,10 @@ void NotificationSettingsManager::send_get_scope_notification_settings_query(Not
|
||||
}
|
||||
|
||||
void NotificationSettingsManager::on_get_dialog_notification_settings_query_finished(DialogId dialog_id,
|
||||
MessageId top_thread_message_id,
|
||||
Status &&status) {
|
||||
CHECK(!td_->auth_manager_->is_bot());
|
||||
auto it = get_dialog_notification_settings_queries_.find(dialog_id);
|
||||
auto it = get_dialog_notification_settings_queries_.find({dialog_id, top_thread_message_id});
|
||||
CHECK(it != get_dialog_notification_settings_queries_.end());
|
||||
CHECK(!it->second.empty());
|
||||
auto promises = std::move(it->second);
|
||||
@ -1398,10 +1419,11 @@ void NotificationSettingsManager::on_get_dialog_notification_settings_query_fini
|
||||
}
|
||||
}
|
||||
|
||||
void NotificationSettingsManager::update_dialog_notify_settings(DialogId dialog_id,
|
||||
void NotificationSettingsManager::update_dialog_notify_settings(DialogId dialog_id, MessageId top_thread_message_id,
|
||||
const DialogNotificationSettings &new_settings,
|
||||
Promise<Unit> &&promise) {
|
||||
td_->create_handler<UpdateDialogNotifySettingsQuery>(std::move(promise))->send(dialog_id, new_settings);
|
||||
td_->create_handler<UpdateDialogNotifySettingsQuery>(std::move(promise))
|
||||
->send(dialog_id, top_thread_message_id, new_settings);
|
||||
}
|
||||
|
||||
Status NotificationSettingsManager::set_scope_notification_settings(
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include "td/telegram/DialogNotificationSettings.h"
|
||||
#include "td/telegram/files/FileId.h"
|
||||
#include "td/telegram/files/FileSourceId.h"
|
||||
#include "td/telegram/FullMessageId.h"
|
||||
#include "td/telegram/MessageId.h"
|
||||
#include "td/telegram/NotificationSettingsScope.h"
|
||||
#include "td/telegram/ScopeNotificationSettings.h"
|
||||
#include "td/telegram/td_api.h"
|
||||
@ -52,7 +54,8 @@ class NotificationSettingsManager final : public Actor {
|
||||
|
||||
bool get_scope_disable_mention_notifications(NotificationSettingsScope scope) const;
|
||||
|
||||
tl_object_ptr<telegram_api::InputNotifyPeer> get_input_notify_peer(DialogId dialog_id) const;
|
||||
tl_object_ptr<telegram_api::InputNotifyPeer> get_input_notify_peer(DialogId dialog_id,
|
||||
MessageId top_thread_message_id) const;
|
||||
|
||||
void on_update_scope_notify_settings(NotificationSettingsScope scope,
|
||||
tl_object_ptr<telegram_api::peerNotifySettings> &&peer_notify_settings);
|
||||
@ -75,16 +78,18 @@ class NotificationSettingsManager final : public Actor {
|
||||
void send_save_ringtone_query(FileId ringtone_file_id, bool unsave,
|
||||
Promise<telegram_api::object_ptr<telegram_api::account_SavedRingtone>> &&promise);
|
||||
|
||||
void send_get_dialog_notification_settings_query(DialogId dialog_id, Promise<Unit> &&promise);
|
||||
void send_get_dialog_notification_settings_query(DialogId dialog_id, MessageId top_thread_message_id,
|
||||
Promise<Unit> &&promise);
|
||||
|
||||
const ScopeNotificationSettings *get_scope_notification_settings(NotificationSettingsScope scope,
|
||||
Promise<Unit> &&promise);
|
||||
void send_get_scope_notification_settings_query(NotificationSettingsScope scope, Promise<Unit> &&promise);
|
||||
|
||||
void on_get_dialog_notification_settings_query_finished(DialogId dialog_id, Status &&status);
|
||||
void on_get_dialog_notification_settings_query_finished(DialogId dialog_id, MessageId top_thread_message_id,
|
||||
Status &&status);
|
||||
|
||||
void update_dialog_notify_settings(DialogId dialog_id, const DialogNotificationSettings &new_settings,
|
||||
Promise<Unit> &&promise);
|
||||
void update_dialog_notify_settings(DialogId dialog_id, MessageId top_thread_message_id,
|
||||
const DialogNotificationSettings &new_settings, Promise<Unit> &&promise);
|
||||
|
||||
Status set_scope_notification_settings(NotificationSettingsScope scope,
|
||||
td_api::object_ptr<td_api::scopeNotificationSettings> &¬ification_settings)
|
||||
@ -211,7 +216,7 @@ class NotificationSettingsManager final : public Actor {
|
||||
vector<Promise<Unit>> reload_saved_ringtones_queries_;
|
||||
vector<Promise<Unit>> repair_saved_ringtones_queries_;
|
||||
|
||||
FlatHashMap<DialogId, vector<Promise<Unit>>, DialogIdHash> get_dialog_notification_settings_queries_;
|
||||
FlatHashMap<FullMessageId, vector<Promise<Unit>>, FullMessageIdHash> get_dialog_notification_settings_queries_;
|
||||
};
|
||||
|
||||
} // namespace td
|
||||
|
@ -7424,6 +7424,13 @@ void Td::on_request(uint64 id, td_api::setChatNotificationSettings &request) {
|
||||
std::move(request.notification_settings_)));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::setForumTopicNotificationSettings &request) {
|
||||
CHECK_IS_USER();
|
||||
answer_ok_query(id, forum_topic_manager_->set_forum_topic_notification_settings(
|
||||
DialogId(request.chat_id_), MessageId(request.message_thread_id_),
|
||||
std::move(request.notification_settings_)));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::setScopeNotificationSettings &request) {
|
||||
CHECK_IS_USER();
|
||||
if (request.scope_ == nullptr) {
|
||||
|
@ -1218,6 +1218,8 @@ class Td final : public Actor {
|
||||
|
||||
void on_request(uint64 id, td_api::setChatNotificationSettings &request);
|
||||
|
||||
void on_request(uint64 id, td_api::setForumTopicNotificationSettings &request);
|
||||
|
||||
void on_request(uint64 id, td_api::setScopeNotificationSettings &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::resetAllNotificationSettings &request);
|
||||
|
@ -4880,29 +4880,37 @@ class CliClient final : public Actor {
|
||||
as_notification_settings_scope(args), op == "gcnses"));
|
||||
} else if (op == "gsns") {
|
||||
send_request(td_api::make_object<td_api::getScopeNotificationSettings>(as_notification_settings_scope(args)));
|
||||
} else if (op == "scns" || op == "ssns") {
|
||||
string chat_id_or_scope;
|
||||
} else if (op == "scns" || op == "ssns" || op == "sftns") {
|
||||
string scope;
|
||||
string mute_for;
|
||||
int64 sound_id;
|
||||
string show_preview;
|
||||
string disable_pinned_message_notifications;
|
||||
string disable_mention_notifications;
|
||||
get_args(args, chat_id_or_scope, mute_for, sound_id, show_preview, disable_pinned_message_notifications,
|
||||
get_args(args, scope, mute_for, sound_id, show_preview, disable_pinned_message_notifications,
|
||||
disable_mention_notifications);
|
||||
if (op == "scns") {
|
||||
send_request(td_api::make_object<td_api::setChatNotificationSettings>(
|
||||
as_chat_id(chat_id_or_scope),
|
||||
td_api::make_object<td_api::chatNotificationSettings>(
|
||||
mute_for.empty(), to_integer<int32>(mute_for), sound_id == -1, sound_id, show_preview.empty(),
|
||||
as_bool(show_preview), disable_pinned_message_notifications.empty(),
|
||||
as_bool(disable_pinned_message_notifications), disable_mention_notifications.empty(),
|
||||
as_bool(disable_mention_notifications))));
|
||||
} else {
|
||||
if (op == "ssns") {
|
||||
send_request(td_api::make_object<td_api::setScopeNotificationSettings>(
|
||||
as_notification_settings_scope(chat_id_or_scope),
|
||||
as_notification_settings_scope(scope),
|
||||
td_api::make_object<td_api::scopeNotificationSettings>(
|
||||
to_integer<int32>(mute_for), sound_id, as_bool(show_preview),
|
||||
as_bool(disable_pinned_message_notifications), as_bool(disable_mention_notifications))));
|
||||
} else {
|
||||
auto settings = td_api::make_object<td_api::chatNotificationSettings>(
|
||||
mute_for.empty(), to_integer<int32>(mute_for), sound_id == -1, sound_id, show_preview.empty(),
|
||||
as_bool(show_preview), disable_pinned_message_notifications.empty(),
|
||||
as_bool(disable_pinned_message_notifications), disable_mention_notifications.empty(),
|
||||
as_bool(disable_mention_notifications));
|
||||
if (op == "scns") {
|
||||
send_request(
|
||||
td_api::make_object<td_api::setChatNotificationSettings>(as_chat_id(scope), std::move(settings)));
|
||||
} else {
|
||||
string chat_id;
|
||||
string message_id;
|
||||
std::tie(chat_id, message_id) = split(scope, ',');
|
||||
send_request(td_api::make_object<td_api::setForumTopicNotificationSettings>(
|
||||
as_chat_id(chat_id), as_message_id(message_id), std::move(settings)));
|
||||
}
|
||||
}
|
||||
} else if (op == "rans") {
|
||||
send_request(td_api::make_object<td_api::resetAllNotificationSettings>());
|
||||
|
Loading…
Reference in New Issue
Block a user