Add DC_UPDATE push processing.

GitOrigin-RevId: f45e00f221744eb3c4b5d2bc70adad78b7fb6554
This commit is contained in:
levlam 2019-03-25 06:51:15 +03:00
parent 0f8b5f89dc
commit 5a4baecf1e

View File

@ -12,6 +12,8 @@
#include "td/telegram/DeviceTokenManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/MessagesManager.h"
#include "td/telegram/net/ConnectionCreator.h"
#include "td/telegram/net/DcId.h"
#include "td/telegram/StateManager.h"
#include "td/telegram/Td.h"
#include "td/telegram/TdDb.h"
@ -2338,6 +2340,17 @@ Status NotificationManager::process_push_notification_payload(string payload) {
return Status::Error("Expected badge to be positive");
}
if (loc_key == "DC_UPDATE") {
TRY_RESULT(dc_id, get_json_object_int_field(custom, "dc", false));
TRY_RESULT(addr, get_json_object_string_field(custom, "addr", false));
if (!DcId::is_valid(dc_id)) {
return Status::Error("Invalid dc id");
}
send_closure(G()->connection_creator(), &ConnectionCreator::on_dc_update, DcId::internal(dc_id), std::move(addr),
Promise<Unit>());
return Status::OK();
}
return Status::OK();
}