Send result of processPushNotification with a small delay.

GitOrigin-RevId: f2530099606505f4e3c4b3bbcde82b0bd762661c
This commit is contained in:
levlam 2019-04-09 02:07:35 +03:00
parent fe9f1e52d2
commit 86471c5ff9
2 changed files with 15 additions and 4 deletions

View File

@ -33,6 +33,8 @@
#include "td/db/binlog/BinlogEvent.h"
#include "td/db/binlog/BinlogHelper.h"
#include "td/actor/SleepActor.h"
#include "td/utils/as.h"
#include "td/utils/base64.h"
#include "td/utils/buffer.h"
@ -2578,7 +2580,15 @@ void NotificationManager::get_disable_contact_registered_notifications(Promise<U
td_->create_handler<GetContactSignUpNotificationQuery>(std::move(promise))->send();
}
void NotificationManager::process_push_notification(string payload, Promise<Unit> &&promise) {
void NotificationManager::process_push_notification(string payload, Promise<Unit> &&user_promise) {
auto promise = PromiseCreator::lambda([user_promise = std::move(user_promise)](Result<Unit> &&result) mutable {
if (result.is_error()) {
user_promise.set_error(result.move_as_error());
} else {
create_actor<SleepActor>("FinishProcessPushNotificationActor", 0.003, std::move(user_promise)).release();
}
});
if (is_disabled() || payload == "{}") {
promise.set_value(Unit());
return;
@ -3220,8 +3230,9 @@ Status NotificationManager::process_push_notification_payload(string payload, Pr
}
break;
case telegram_api::document::ID: {
std::pair<DocumentsManager::DocumentType, FileId> attached_document = td_->documents_manager_->on_get_document(
telegram_api::move_object_as<telegram_api::document>(result), dialog_id);
std::pair<DocumentsManager::DocumentType, FileId> attached_document =
td_->documents_manager_->on_get_document(telegram_api::move_object_as<telegram_api::document>(result),
dialog_id);
switch (attached_document.first) {
case DocumentsManager::DocumentType::Animation:
case DocumentsManager::DocumentType::Audio:

View File

@ -104,7 +104,7 @@ class NotificationManager : public Actor {
void on_get_disable_contact_registered_notifications(bool is_disabled);
void process_push_notification(string payload, Promise<Unit> &&promise);
void process_push_notification(string payload, Promise<Unit> &&user_promise);
static Result<int64> get_push_receiver_id(string push);