2018-11-09 23:56:00 +01:00
|
|
|
//
|
2021-01-01 13:57:46 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2021
|
2018-11-09 23:56:00 +01:00
|
|
|
//
|
|
|
|
// 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/NotificationType.h"
|
|
|
|
|
2019-04-09 22:39:41 +02:00
|
|
|
#include "td/telegram/AnimationsManager.h"
|
|
|
|
#include "td/telegram/AudiosManager.h"
|
|
|
|
#include "td/telegram/DocumentsManager.h"
|
2019-01-06 20:59:17 +01:00
|
|
|
#include "td/telegram/Global.h"
|
2018-11-15 16:58:33 +01:00
|
|
|
#include "td/telegram/MessagesManager.h"
|
2019-04-09 22:39:41 +02:00
|
|
|
#include "td/telegram/StickersManager.h"
|
2018-11-15 16:58:33 +01:00
|
|
|
#include "td/telegram/Td.h"
|
2019-04-09 22:39:41 +02:00
|
|
|
#include "td/telegram/VideoNotesManager.h"
|
2019-04-26 01:21:12 +02:00
|
|
|
#include "td/telegram/VideosManager.h"
|
2019-04-09 22:39:41 +02:00
|
|
|
#include "td/telegram/VoiceNotesManager.h"
|
2018-11-15 16:58:33 +01:00
|
|
|
|
2019-04-05 08:09:58 +02:00
|
|
|
#include "td/utils/misc.h"
|
|
|
|
#include "td/utils/Slice.h"
|
|
|
|
|
2019-04-22 02:46:51 +02:00
|
|
|
#include <tuple>
|
|
|
|
|
2018-11-09 23:56:00 +01:00
|
|
|
namespace td {
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class NotificationTypeMessage final : public NotificationType {
|
2021-07-03 22:51:36 +02:00
|
|
|
bool can_be_delayed() const final {
|
2019-03-26 14:39:15 +01:00
|
|
|
return message_id_.is_valid() && message_id_.is_server();
|
2018-11-15 17:09:01 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
bool is_temporary() const final {
|
2019-03-30 21:49:14 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
MessageId get_message_id() const final {
|
2018-11-20 15:08:44 +01:00
|
|
|
return message_id_;
|
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
vector<FileId> get_file_ids(const Td *td) const final {
|
2019-04-10 00:57:15 +02:00
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
td_api::object_ptr<td_api::NotificationType> get_notification_type_object(DialogId dialog_id) const final {
|
2021-10-03 13:54:40 +02:00
|
|
|
auto message_object = G()->td().get_actor_unsafe()->messages_manager_->get_message_object(
|
|
|
|
{dialog_id, message_id_}, "get_notification_type_object");
|
2018-11-15 16:58:33 +01:00
|
|
|
if (message_object == nullptr) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return td_api::make_object<td_api::notificationTypeNewMessage>(std::move(message_object));
|
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
StringBuilder &to_string_builder(StringBuilder &string_builder) const final {
|
2018-11-09 23:56:00 +01:00
|
|
|
return string_builder << "NewMessageNotification[" << message_id_ << ']';
|
|
|
|
}
|
2019-05-03 22:22:49 +02:00
|
|
|
|
2018-11-09 23:56:00 +01:00
|
|
|
MessageId message_id_;
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit NotificationTypeMessage(MessageId message_id) : message_id_(message_id) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class NotificationTypeSecretChat final : public NotificationType {
|
2021-07-03 22:51:36 +02:00
|
|
|
bool can_be_delayed() const final {
|
2018-11-15 17:09:01 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
bool is_temporary() const final {
|
2019-03-30 21:49:14 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
MessageId get_message_id() const final {
|
2018-11-20 15:08:44 +01:00
|
|
|
return MessageId();
|
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
vector<FileId> get_file_ids(const Td *td) const final {
|
2019-04-10 00:57:15 +02:00
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
td_api::object_ptr<td_api::NotificationType> get_notification_type_object(DialogId dialog_id) const final {
|
2018-11-15 16:58:33 +01:00
|
|
|
return td_api::make_object<td_api::notificationTypeNewSecretChat>();
|
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
StringBuilder &to_string_builder(StringBuilder &string_builder) const final {
|
2018-11-09 23:56:00 +01:00
|
|
|
return string_builder << "NewSecretChatNotification[]";
|
|
|
|
}
|
2019-05-03 22:22:49 +02:00
|
|
|
|
2018-11-09 23:56:00 +01:00
|
|
|
public:
|
|
|
|
NotificationTypeSecretChat() {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class NotificationTypeCall final : public NotificationType {
|
2021-07-03 22:51:36 +02:00
|
|
|
bool can_be_delayed() const final {
|
2018-11-15 17:09:01 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
bool is_temporary() const final {
|
2019-03-30 21:49:14 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
MessageId get_message_id() const final {
|
2018-11-22 18:17:26 +01:00
|
|
|
return MessageId::max();
|
2018-11-20 15:08:44 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
vector<FileId> get_file_ids(const Td *td) const final {
|
2019-04-10 00:57:15 +02:00
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
td_api::object_ptr<td_api::NotificationType> get_notification_type_object(DialogId dialog_id) const final {
|
2018-11-15 16:58:33 +01:00
|
|
|
return td_api::make_object<td_api::notificationTypeNewCall>(call_id_.get());
|
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
StringBuilder &to_string_builder(StringBuilder &string_builder) const final {
|
2018-11-09 23:56:00 +01:00
|
|
|
return string_builder << "NewCallNotification[" << call_id_ << ']';
|
|
|
|
}
|
2019-05-03 22:22:49 +02:00
|
|
|
|
2018-11-09 23:56:00 +01:00
|
|
|
CallId call_id_;
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit NotificationTypeCall(CallId call_id) : call_id_(call_id) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class NotificationTypePushMessage final : public NotificationType {
|
2021-07-03 22:51:36 +02:00
|
|
|
bool can_be_delayed() const final {
|
2019-03-28 22:08:57 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
bool is_temporary() const final {
|
2019-03-30 21:49:14 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
MessageId get_message_id() const final {
|
2019-03-28 22:08:57 +01:00
|
|
|
return message_id_;
|
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
vector<FileId> get_file_ids(const Td *td) const final {
|
2019-04-10 00:57:15 +02:00
|
|
|
if (!document_.empty()) {
|
|
|
|
return document_.get_file_ids(td);
|
|
|
|
}
|
|
|
|
|
|
|
|
return photo_get_file_ids(photo_);
|
|
|
|
}
|
|
|
|
|
2019-04-09 16:33:27 +02:00
|
|
|
static td_api::object_ptr<td_api::PushMessageContent> get_push_message_content_object(Slice key, const string &arg,
|
2019-04-09 22:39:41 +02:00
|
|
|
const Photo &photo,
|
|
|
|
const Document &document) {
|
2019-04-05 08:09:58 +02:00
|
|
|
bool is_pinned = false;
|
|
|
|
if (begins_with(key, "PINNED_")) {
|
|
|
|
is_pinned = true;
|
|
|
|
key = key.substr(7);
|
|
|
|
}
|
|
|
|
if (key == "MESSAGE") {
|
|
|
|
return td_api::make_object<td_api::pushMessageContentHidden>(is_pinned);
|
|
|
|
}
|
|
|
|
if (key == "MESSAGES") {
|
2020-10-20 12:21:09 +02:00
|
|
|
return td_api::make_object<td_api::pushMessageContentMediaAlbum>(to_integer<int32>(arg), true, true, false,
|
|
|
|
false);
|
2019-04-05 08:09:58 +02:00
|
|
|
}
|
|
|
|
CHECK(key.size() > 8);
|
|
|
|
switch (key[8]) {
|
|
|
|
case 'A':
|
|
|
|
if (key == "MESSAGE_ANIMATION") {
|
2019-04-09 22:39:41 +02:00
|
|
|
auto animations_manager = G()->td().get_actor_unsafe()->animations_manager_.get();
|
|
|
|
return td_api::make_object<td_api::pushMessageContentAnimation>(
|
2021-08-28 13:16:29 +02:00
|
|
|
animations_manager->get_animation_object(document.file_id), arg, is_pinned);
|
2019-04-09 22:39:41 +02:00
|
|
|
}
|
|
|
|
if (key == "MESSAGE_AUDIO") {
|
|
|
|
auto audios_manager = G()->td().get_actor_unsafe()->audios_manager_.get();
|
|
|
|
return td_api::make_object<td_api::pushMessageContentAudio>(
|
2019-04-15 15:33:57 +02:00
|
|
|
audios_manager->get_audio_object(document.file_id), is_pinned);
|
2019-04-05 08:09:58 +02:00
|
|
|
}
|
2020-10-20 12:21:09 +02:00
|
|
|
if (key == "MESSAGE_AUDIOS") {
|
|
|
|
return td_api::make_object<td_api::pushMessageContentMediaAlbum>(to_integer<int32>(arg), false, false, true,
|
|
|
|
false);
|
|
|
|
}
|
2019-04-05 08:09:58 +02:00
|
|
|
break;
|
|
|
|
case 'B':
|
|
|
|
if (key == "MESSAGE_BASIC_GROUP_CHAT_CREATE") {
|
|
|
|
return td_api::make_object<td_api::pushMessageContentBasicGroupChatCreate>();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'C':
|
|
|
|
if (key == "MESSAGE_CHAT_ADD_MEMBERS") {
|
|
|
|
return td_api::make_object<td_api::pushMessageContentChatAddMembers>(arg, false, false);
|
|
|
|
}
|
|
|
|
if (key == "MESSAGE_CHAT_ADD_MEMBERS_RETURNED") {
|
|
|
|
return td_api::make_object<td_api::pushMessageContentChatAddMembers>(arg, false, true);
|
|
|
|
}
|
|
|
|
if (key == "MESSAGE_CHAT_ADD_MEMBERS_YOU") {
|
|
|
|
return td_api::make_object<td_api::pushMessageContentChatAddMembers>(arg, true, false);
|
|
|
|
}
|
|
|
|
if (key == "MESSAGE_CHAT_CHANGE_PHOTO") {
|
|
|
|
return td_api::make_object<td_api::pushMessageContentChatChangePhoto>();
|
|
|
|
}
|
2021-08-27 15:38:05 +02:00
|
|
|
if (key == "MESSAGE_CHAT_CHANGE_THEME") {
|
2021-09-24 09:42:39 +02:00
|
|
|
return td_api::make_object<td_api::pushMessageContentChatSetTheme>(arg);
|
2021-08-27 15:38:05 +02:00
|
|
|
}
|
2019-04-05 08:09:58 +02:00
|
|
|
if (key == "MESSAGE_CHAT_CHANGE_TITLE") {
|
2019-04-09 22:43:53 +02:00
|
|
|
return td_api::make_object<td_api::pushMessageContentChatChangeTitle>(arg);
|
2019-04-05 08:09:58 +02:00
|
|
|
}
|
|
|
|
if (key == "MESSAGE_CHAT_DELETE_MEMBER") {
|
|
|
|
return td_api::make_object<td_api::pushMessageContentChatDeleteMember>(arg, false, false);
|
|
|
|
}
|
|
|
|
if (key == "MESSAGE_CHAT_DELETE_MEMBER_LEFT") {
|
|
|
|
return td_api::make_object<td_api::pushMessageContentChatDeleteMember>(arg, false, true);
|
|
|
|
}
|
|
|
|
if (key == "MESSAGE_CHAT_DELETE_MEMBER_YOU") {
|
|
|
|
return td_api::make_object<td_api::pushMessageContentChatDeleteMember>(arg, true, false);
|
|
|
|
}
|
|
|
|
if (key == "MESSAGE_CHAT_JOIN_BY_LINK") {
|
|
|
|
return td_api::make_object<td_api::pushMessageContentChatJoinByLink>();
|
|
|
|
}
|
|
|
|
if (key == "MESSAGE_CONTACT") {
|
|
|
|
return td_api::make_object<td_api::pushMessageContentContact>(arg, is_pinned);
|
|
|
|
}
|
|
|
|
if (key == "MESSAGE_CONTACT_REGISTERED") {
|
|
|
|
return td_api::make_object<td_api::pushMessageContentContactRegistered>();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'D':
|
|
|
|
if (key == "MESSAGE_DOCUMENT") {
|
2019-04-09 22:39:41 +02:00
|
|
|
auto documents_manager = G()->td().get_actor_unsafe()->documents_manager_.get();
|
|
|
|
return td_api::make_object<td_api::pushMessageContentDocument>(
|
2020-05-31 21:22:15 +02:00
|
|
|
documents_manager->get_document_object(document.file_id, PhotoFormat::Jpeg), is_pinned);
|
2019-04-05 08:09:58 +02:00
|
|
|
}
|
2020-10-20 12:21:09 +02:00
|
|
|
if (key == "MESSAGE_DOCUMENTS") {
|
|
|
|
return td_api::make_object<td_api::pushMessageContentMediaAlbum>(to_integer<int32>(arg), false, false, false,
|
|
|
|
true);
|
|
|
|
}
|
2019-04-05 08:09:58 +02:00
|
|
|
break;
|
|
|
|
case 'F':
|
|
|
|
if (key == "MESSAGE_FORWARDS") {
|
|
|
|
return td_api::make_object<td_api::pushMessageContentMessageForwards>(to_integer<int32>(arg));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'G':
|
|
|
|
if (key == "MESSAGE_GAME") {
|
|
|
|
return td_api::make_object<td_api::pushMessageContentGame>(arg, is_pinned);
|
|
|
|
}
|
|
|
|
if (key == "MESSAGE_GAME_SCORE") {
|
|
|
|
int32 score = 0;
|
|
|
|
string title;
|
|
|
|
if (!is_pinned) {
|
|
|
|
string score_str;
|
|
|
|
std::tie(score_str, title) = split(arg);
|
|
|
|
score = to_integer<int32>(score_str);
|
|
|
|
}
|
|
|
|
return td_api::make_object<td_api::pushMessageContentGameScore>(title, score, is_pinned);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'I':
|
|
|
|
if (key == "MESSAGE_INVOICE") {
|
|
|
|
return td_api::make_object<td_api::pushMessageContentInvoice>(arg, is_pinned);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'L':
|
|
|
|
if (key == "MESSAGE_LIVE_LOCATION") {
|
|
|
|
return td_api::make_object<td_api::pushMessageContentLocation>(false, is_pinned);
|
|
|
|
}
|
|
|
|
if (key == "MESSAGE_LOCATION") {
|
|
|
|
return td_api::make_object<td_api::pushMessageContentLocation>(true, is_pinned);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'P':
|
|
|
|
if (key == "MESSAGE_PHOTO") {
|
2019-04-09 16:33:27 +02:00
|
|
|
auto file_manager = G()->td().get_actor_unsafe()->file_manager_.get();
|
2020-07-06 17:45:43 +02:00
|
|
|
return td_api::make_object<td_api::pushMessageContentPhoto>(get_photo_object(file_manager, photo), arg, false,
|
|
|
|
is_pinned);
|
2019-04-05 08:09:58 +02:00
|
|
|
}
|
|
|
|
if (key == "MESSAGE_PHOTOS") {
|
2020-10-20 12:21:09 +02:00
|
|
|
return td_api::make_object<td_api::pushMessageContentMediaAlbum>(to_integer<int32>(arg), true, false, false,
|
|
|
|
false);
|
2019-04-05 08:09:58 +02:00
|
|
|
}
|
|
|
|
if (key == "MESSAGE_POLL") {
|
2020-01-21 02:29:35 +01:00
|
|
|
return td_api::make_object<td_api::pushMessageContentPoll>(arg, true, is_pinned);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'Q':
|
|
|
|
if (key == "MESSAGE_QUIZ") {
|
|
|
|
return td_api::make_object<td_api::pushMessageContentPoll>(arg, false, is_pinned);
|
2019-04-05 08:09:58 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'S':
|
|
|
|
if (key == "MESSAGE_SECRET_PHOTO") {
|
2019-04-09 16:33:27 +02:00
|
|
|
return td_api::make_object<td_api::pushMessageContentPhoto>(nullptr, arg, true, false);
|
2019-04-05 08:09:58 +02:00
|
|
|
}
|
|
|
|
if (key == "MESSAGE_SECRET_VIDEO") {
|
2019-04-09 22:39:41 +02:00
|
|
|
return td_api::make_object<td_api::pushMessageContentVideo>(nullptr, arg, true, false);
|
2019-04-05 08:09:58 +02:00
|
|
|
}
|
|
|
|
if (key == "MESSAGE_SCREENSHOT_TAKEN") {
|
|
|
|
return td_api::make_object<td_api::pushMessageContentScreenshotTaken>();
|
|
|
|
}
|
|
|
|
if (key == "MESSAGE_STICKER") {
|
2019-04-09 22:39:41 +02:00
|
|
|
auto stickers_manager = G()->td().get_actor_unsafe()->stickers_manager_.get();
|
|
|
|
return td_api::make_object<td_api::pushMessageContentSticker>(
|
2019-04-15 15:33:57 +02:00
|
|
|
stickers_manager->get_sticker_object(document.file_id), trim(arg), is_pinned);
|
2019-04-05 08:09:58 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'T':
|
|
|
|
if (key == "MESSAGE_TEXT") {
|
|
|
|
return td_api::make_object<td_api::pushMessageContentText>(arg, is_pinned);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'V':
|
|
|
|
if (key == "MESSAGE_VIDEO") {
|
2019-04-09 22:39:41 +02:00
|
|
|
auto videos_manager = G()->td().get_actor_unsafe()->videos_manager_.get();
|
|
|
|
return td_api::make_object<td_api::pushMessageContentVideo>(
|
|
|
|
videos_manager->get_video_object(document.file_id), arg, false, is_pinned);
|
2019-04-05 08:09:58 +02:00
|
|
|
}
|
|
|
|
if (key == "MESSAGE_VIDEO_NOTE") {
|
2019-04-09 22:39:41 +02:00
|
|
|
auto video_notes_manager = G()->td().get_actor_unsafe()->video_notes_manager_.get();
|
|
|
|
return td_api::make_object<td_api::pushMessageContentVideoNote>(
|
|
|
|
video_notes_manager->get_video_note_object(document.file_id), is_pinned);
|
2019-04-05 08:09:58 +02:00
|
|
|
}
|
|
|
|
if (key == "MESSAGE_VIDEOS") {
|
2020-10-20 12:21:09 +02:00
|
|
|
return td_api::make_object<td_api::pushMessageContentMediaAlbum>(to_integer<int32>(arg), false, true, false,
|
|
|
|
false);
|
2019-04-05 08:09:58 +02:00
|
|
|
}
|
|
|
|
if (key == "MESSAGE_VOICE_NOTE") {
|
2019-04-09 22:39:41 +02:00
|
|
|
auto voice_notes_manager = G()->td().get_actor_unsafe()->voice_notes_manager_.get();
|
|
|
|
return td_api::make_object<td_api::pushMessageContentVoiceNote>(
|
2019-04-15 15:33:57 +02:00
|
|
|
voice_notes_manager->get_voice_note_object(document.file_id), is_pinned);
|
2019-04-05 08:09:58 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
td_api::object_ptr<td_api::NotificationType> get_notification_type_object(DialogId dialog_id) const final {
|
2021-08-03 00:58:02 +02:00
|
|
|
auto sender = G()->td().get_actor_unsafe()->messages_manager_->get_message_sender_object(
|
|
|
|
sender_user_id_, sender_dialog_id_, "get_notification_type_object");
|
2019-04-09 16:33:27 +02:00
|
|
|
return td_api::make_object<td_api::notificationTypeNewPushMessage>(
|
2020-10-13 18:40:22 +02:00
|
|
|
message_id_.get(), std::move(sender), sender_name_, is_outgoing_,
|
2020-02-18 14:04:37 +01:00
|
|
|
get_push_message_content_object(key_, arg_, photo_, document_));
|
2019-03-28 22:08:57 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
StringBuilder &to_string_builder(StringBuilder &string_builder) const final {
|
2020-09-08 21:08:10 +02:00
|
|
|
return string_builder << "NewPushMessageNotification[" << sender_user_id_ << "/" << sender_dialog_id_ << "/\""
|
|
|
|
<< sender_name_ << "\", " << message_id_ << ", " << key_ << ", " << arg_ << ", " << photo_
|
|
|
|
<< ", " << document_ << ']';
|
2019-03-28 22:08:57 +01:00
|
|
|
}
|
2019-05-03 22:22:49 +02:00
|
|
|
|
2019-03-30 15:59:35 +01:00
|
|
|
UserId sender_user_id_;
|
2020-09-08 21:08:10 +02:00
|
|
|
DialogId sender_dialog_id_;
|
2019-03-28 22:08:57 +01:00
|
|
|
MessageId message_id_;
|
2020-02-18 14:04:37 +01:00
|
|
|
string sender_name_;
|
2019-03-28 22:08:57 +01:00
|
|
|
string key_;
|
|
|
|
string arg_;
|
2019-04-09 16:33:27 +02:00
|
|
|
Photo photo_;
|
2019-04-09 22:39:41 +02:00
|
|
|
Document document_;
|
2020-02-29 19:42:02 +01:00
|
|
|
bool is_outgoing_;
|
2019-03-28 22:08:57 +01:00
|
|
|
|
|
|
|
public:
|
2020-09-08 21:08:10 +02:00
|
|
|
NotificationTypePushMessage(UserId sender_user_id, DialogId sender_dialog_id, string sender_name, bool is_outgoing,
|
|
|
|
MessageId message_id, string key, string arg, Photo photo, Document document)
|
|
|
|
: sender_user_id_(sender_user_id)
|
|
|
|
, sender_dialog_id_(sender_dialog_id)
|
2019-03-28 22:08:57 +01:00
|
|
|
, message_id_(message_id)
|
2020-02-19 03:26:45 +01:00
|
|
|
, sender_name_(std::move(sender_name))
|
2019-03-28 22:08:57 +01:00
|
|
|
, key_(std::move(key))
|
2019-04-09 16:33:27 +02:00
|
|
|
, arg_(std::move(arg))
|
2019-04-09 22:39:41 +02:00
|
|
|
, photo_(std::move(photo))
|
2020-02-29 19:42:02 +01:00
|
|
|
, document_(std::move(document))
|
|
|
|
, is_outgoing_(is_outgoing) {
|
2019-03-28 22:08:57 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-11-09 23:56:00 +01:00
|
|
|
unique_ptr<NotificationType> create_new_message_notification(MessageId message_id) {
|
|
|
|
return make_unique<NotificationTypeMessage>(message_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
unique_ptr<NotificationType> create_new_secret_chat_notification() {
|
|
|
|
return make_unique<NotificationTypeSecretChat>();
|
|
|
|
}
|
|
|
|
|
|
|
|
unique_ptr<NotificationType> create_new_call_notification(CallId call_id) {
|
|
|
|
return make_unique<NotificationTypeCall>(call_id);
|
|
|
|
}
|
|
|
|
|
2020-09-08 21:08:10 +02:00
|
|
|
unique_ptr<NotificationType> create_new_push_message_notification(UserId sender_user_id, DialogId sender_dialog_id,
|
|
|
|
string sender_name, bool is_outgoing,
|
|
|
|
MessageId message_id, string key, string arg,
|
|
|
|
Photo photo, Document document) {
|
|
|
|
return td::make_unique<NotificationTypePushMessage>(sender_user_id, sender_dialog_id, std::move(sender_name),
|
|
|
|
is_outgoing, message_id, std::move(key), std::move(arg),
|
|
|
|
std::move(photo), std::move(document));
|
2019-03-28 22:08:57 +01:00
|
|
|
}
|
|
|
|
|
2018-11-09 23:56:00 +01:00
|
|
|
} // namespace td
|