Add dummy NotificationManager.
GitOrigin-RevId: f8915918dfa91562b7acad45133c1c493affc896
This commit is contained in:
parent
9fa8186287
commit
5f23a99fca
@ -404,6 +404,7 @@ set(TDLIB_SOURCE
|
||||
td/telegram/net/Session.cpp
|
||||
td/telegram/net/SessionProxy.cpp
|
||||
td/telegram/net/SessionMultiProxy.cpp
|
||||
td/telegram/NotificationManager.cpp
|
||||
td/telegram/NotificationSettings.cpp
|
||||
td/telegram/Payments.cpp
|
||||
td/telegram/PasswordManager.cpp
|
||||
@ -533,6 +534,7 @@ set(TDLIB_SOURCE
|
||||
td/telegram/net/SessionProxy.h
|
||||
td/telegram/net/SessionMultiProxy.h
|
||||
td/telegram/net/TempAuthKeyWatchdog.h
|
||||
td/telegram/NotificationManager.h
|
||||
td/telegram/NotificationSettings.h
|
||||
td/telegram/PasswordManager.h
|
||||
td/telegram/Payments.h
|
||||
|
41
td/telegram/NotificationManager.cpp
Normal file
41
td/telegram/NotificationManager.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
//
|
||||
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
#include "td/telegram/NotificationManager.h"
|
||||
|
||||
#include "td/telegram/Td.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
NotificationManager::NotificationManager(Td *td) : td_(td) {
|
||||
}
|
||||
|
||||
void NotificationManager::remove_notification(int32 notification_id, Promise<Unit> &&promise) {
|
||||
if (!is_valid_notification_id(notification_id)) {
|
||||
return promise.set_error(Status::Error(400, "Notification identifier is invalid"));
|
||||
}
|
||||
promise.set_value(Unit());
|
||||
}
|
||||
|
||||
void NotificationManager::remove_notifications(int32 group_id, int32 max_notification_id, Promise<Unit> &&promise) {
|
||||
if (!is_valid_group_id(group_id)) {
|
||||
return promise.set_error(Status::Error(400, "Group identifier is invalid"));
|
||||
}
|
||||
if (!is_valid_notification_id(max_notification_id)) {
|
||||
return promise.set_error(Status::Error(400, "Notification identifier is invalid"));
|
||||
}
|
||||
promise.set_value(Unit());
|
||||
}
|
||||
|
||||
bool NotificationManager::is_valid_notification_id(int32 notification_id) {
|
||||
return notification_id > 0;
|
||||
}
|
||||
|
||||
bool NotificationManager::is_valid_group_id(int32 group_id) {
|
||||
return group_id > 0;
|
||||
}
|
||||
|
||||
} // namespace td
|
31
td/telegram/NotificationManager.h
Normal file
31
td/telegram/NotificationManager.h
Normal file
@ -0,0 +1,31 @@
|
||||
//
|
||||
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include "td/actor/PromiseFuture.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
class Td;
|
||||
|
||||
class NotificationManager {
|
||||
public:
|
||||
explicit NotificationManager(Td *td);
|
||||
|
||||
void remove_notification(int32 notification_id, Promise<Unit> &&promise);
|
||||
|
||||
void remove_notifications(int32 group_id, int32 max_notification_id, Promise<Unit> &&promise);
|
||||
|
||||
private:
|
||||
static bool is_valid_notification_id(int32 notification_id);
|
||||
|
||||
static bool is_valid_group_id(int32 group_id);
|
||||
|
||||
Td *td_;
|
||||
};
|
||||
|
||||
} // namespace td
|
@ -44,6 +44,7 @@
|
||||
#include "td/telegram/MessageId.h"
|
||||
#include "td/telegram/MessagesManager.h"
|
||||
#include "td/telegram/misc.h"
|
||||
#include "td/telegram/NotificationManager.h"
|
||||
#include "td/telegram/NotificationSettings.h"
|
||||
#include "td/telegram/PasswordManager.h"
|
||||
#include "td/telegram/Payments.h"
|
||||
@ -3603,6 +3604,8 @@ void Td::dec_actor_refcnt() {
|
||||
LOG(DEBUG) << "InlineQueriesManager was cleared " << timer;
|
||||
messages_manager_.reset();
|
||||
LOG(DEBUG) << "MessagesManager was cleared " << timer;
|
||||
notification_manager_.reset();
|
||||
LOG(DEBUG) << "NotificationManager was cleared " << timer;
|
||||
stickers_manager_.reset();
|
||||
LOG(DEBUG) << "StickersManager was cleared " << timer;
|
||||
updates_manager_.reset();
|
||||
@ -4023,6 +4026,7 @@ Status Td::init(DbKey key) {
|
||||
audios_manager_ = make_unique<AudiosManager>(this);
|
||||
callback_queries_manager_ = make_unique<CallbackQueriesManager>(this);
|
||||
documents_manager_ = make_unique<DocumentsManager>(this);
|
||||
notification_manager_ = make_unique<NotificationManager>(this);
|
||||
video_notes_manager_ = make_unique<VideoNotesManager>(this);
|
||||
videos_manager_ = make_unique<VideosManager>(this);
|
||||
voice_notes_manager_ = make_unique<VoiceNotesManager>(this);
|
||||
@ -5063,13 +5067,14 @@ void Td::on_request(uint64 id, td_api::getChatMessageCount &request) {
|
||||
void Td::on_request(uint64 id, const td_api::removeNotification &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
// TODO notification_manager->remove_notification(request.notification_id_, std::move(promise));
|
||||
notification_manager_->remove_notification(request.notification_id_, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::removeNotifications &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
// TODO notification_manager->remove_notifications(request.notification_group_id_, request.max_notification_id_, std::move(promise));
|
||||
notification_manager_->remove_notifications(request.notification_group_id_, request.max_notification_id_,
|
||||
std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::deleteMessages &request) {
|
||||
|
@ -49,6 +49,7 @@ class HashtagHints;
|
||||
class LanguagePackManager;
|
||||
class MessagesManager;
|
||||
class NetStatsManager;
|
||||
class NotificationManager;
|
||||
class PasswordManager;
|
||||
class PhoneNumberManager;
|
||||
class PrivacyManager;
|
||||
@ -125,6 +126,7 @@ class Td final : public NetQueryCallback {
|
||||
unique_ptr<AudiosManager> audios_manager_;
|
||||
unique_ptr<CallbackQueriesManager> callback_queries_manager_;
|
||||
unique_ptr<DocumentsManager> documents_manager_;
|
||||
unique_ptr<NotificationManager> notification_manager_;
|
||||
unique_ptr<VideoNotesManager> video_notes_manager_;
|
||||
unique_ptr<VideosManager> videos_manager_;
|
||||
unique_ptr<VoiceNotesManager> voice_notes_manager_;
|
||||
|
@ -3292,6 +3292,15 @@ class CliClient final : public Actor {
|
||||
to_integer<int32>(mute_for), sound, as_bool(show_previews))));
|
||||
} else if (op == "rans") {
|
||||
send_request(make_tl_object<td_api::resetAllNotificationSettings>());
|
||||
} else if (op == "rn") {
|
||||
string notification_id = args;
|
||||
send_request(make_tl_object<td_api::removeNotification>(to_integer<int32>(notification_id)));
|
||||
} else if (op == "rns") {
|
||||
string group_id;
|
||||
string max_notification_id;
|
||||
std::tie(group_id, max_notification_id) = split(args);
|
||||
send_request(make_tl_object<td_api::removeNotifications>(to_integer<int32>(group_id),
|
||||
to_integer<int32>(max_notification_id)));
|
||||
} else if (op == "gcrss") {
|
||||
send_request(make_tl_object<td_api::getChatReportSpamState>(as_chat_id(args)));
|
||||
} else if (op == "ccrss") {
|
||||
|
Reference in New Issue
Block a user