2018-11-09 23:56:00 +01:00
|
|
|
//
|
2022-12-31 22:28:08 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
|
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"
|
2021-11-14 23:18:47 +01:00
|
|
|
#include "td/telegram/MessageSender.h"
|
2018-11-15 16:58:33 +01:00
|
|
|
#include "td/telegram/MessagesManager.h"
|
2022-04-09 22:21:07 +02:00
|
|
|
#include "td/telegram/PhotoFormat.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;
|
|
|
|
}
|
|
|
|
|
2023-08-25 01:04:44 +02:00
|
|
|
NotificationObjectId get_object_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 {};
|
|
|
|
}
|
|
|
|
|
2023-06-24 23:09:48 +02:00
|
|
|
td_api::object_ptr<td_api::NotificationType> get_notification_type_object(Td *td, DialogId dialog_id) const final {
|
|
|
|
auto message_object =
|
|
|
|
td->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;
|
|
|
|
}
|
2022-06-16 17:54:50 +02:00
|
|
|
return td_api::make_object<td_api::notificationTypeNewMessage>(std::move(message_object), show_preview_);
|
2018-11-15 16:58:33 +01:00
|
|
|
}
|
|
|
|
|
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_;
|
2022-06-16 17:54:50 +02:00
|
|
|
bool show_preview_;
|
2018-11-09 23:56:00 +01:00
|
|
|
|
|
|
|
public:
|
2022-06-16 17:54:50 +02:00
|
|
|
NotificationTypeMessage(MessageId message_id, bool show_preview)
|
|
|
|
: message_id_(message_id), show_preview_(show_preview) {
|
2018-11-09 23:56:00 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2023-08-25 01:04:44 +02:00
|
|
|
NotificationObjectId get_object_id() const final {
|
|
|
|
return NotificationObjectId();
|
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 {};
|
|
|
|
}
|
|
|
|
|
2023-06-24 23:09:48 +02:00
|
|
|
td_api::object_ptr<td_api::NotificationType> get_notification_type_object(Td *, DialogId) 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;
|
|
|
|
}
|
|
|
|
|
2023-08-25 01:04:44 +02:00
|
|
|
NotificationObjectId get_object_id() const final {
|
|
|
|
return NotificationObjectId::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 {};
|
|
|
|
}
|
|
|
|
|
2023-06-24 23:09:48 +02:00
|
|
|
td_api::object_ptr<td_api::NotificationType> get_notification_type_object(Td *, DialogId) 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;
|
|
|
|
}
|
|
|
|
|
2023-08-25 01:04:44 +02:00
|
|
|
NotificationObjectId get_object_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_);
|
|
|
|
}
|
|
|
|
|
2023-06-24 22:53:50 +02:00
|
|
|
static td_api::object_ptr<td_api::PushMessageContent> get_push_message_content_object(Td *td, 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
|
|
|
return td_api::make_object<td_api::pushMessageContentAnimation>(
|
2023-06-24 22:53:50 +02:00
|
|
|
td->animations_manager_->get_animation_object(document.file_id), arg, is_pinned);
|
2019-04-09 22:39:41 +02:00
|
|
|
}
|
|
|
|
if (key == "MESSAGE_AUDIO") {
|
|
|
|
return td_api::make_object<td_api::pushMessageContentAudio>(
|
2023-06-24 22:53:50 +02:00
|
|
|
td->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>();
|
|
|
|
}
|
2021-11-01 15:17:08 +01:00
|
|
|
if (key == "MESSAGE_CHAT_JOIN_BY_REQUEST") {
|
|
|
|
return td_api::make_object<td_api::pushMessageContentChatJoinByRequest>();
|
|
|
|
}
|
2019-04-05 08:09:58 +02:00
|
|
|
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
|
|
|
return td_api::make_object<td_api::pushMessageContentDocument>(
|
2023-06-24 22:53:50 +02:00
|
|
|
td->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);
|
|
|
|
}
|
2023-10-13 12:11:13 +02:00
|
|
|
if (key == "MESSAGE_GIFTCODE") {
|
2023-10-30 17:04:14 +01:00
|
|
|
auto month_count = to_integer<int32>(arg);
|
2023-10-13 12:11:13 +02:00
|
|
|
return td_api::make_object<td_api::pushMessageContentPremiumGiftCode>(month_count);
|
|
|
|
}
|
2023-10-13 12:28:01 +02:00
|
|
|
if (key == "MESSAGE_GIVEAWAY") {
|
|
|
|
int32 user_count = 0;
|
|
|
|
int32 month_count = 0;
|
|
|
|
if (!is_pinned) {
|
|
|
|
string user_count_str;
|
|
|
|
string month_count_str;
|
|
|
|
std::tie(user_count_str, month_count_str) = split(arg);
|
|
|
|
user_count = to_integer<int32>(user_count_str);
|
|
|
|
month_count = to_integer<int32>(month_count_str);
|
|
|
|
}
|
|
|
|
return td_api::make_object<td_api::pushMessageContentPremiumGiveaway>(user_count, month_count, is_pinned);
|
|
|
|
}
|
2019-04-05 08:09:58 +02:00
|
|
|
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") {
|
2023-06-24 22:53:50 +02:00
|
|
|
return td_api::make_object<td_api::pushMessageContentPhoto>(get_photo_object(td->file_manager_.get(), 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;
|
2022-06-16 15:42:36 +02:00
|
|
|
case 'R':
|
|
|
|
if (key == "MESSAGE_RECURRING_PAYMENT") {
|
|
|
|
return td_api::make_object<td_api::pushMessageContentRecurringPayment>(arg);
|
|
|
|
}
|
|
|
|
break;
|
2019-04-05 08:09:58 +02:00
|
|
|
case 'S':
|
2023-04-10 14:14:03 +02:00
|
|
|
if (key == "MESSAGE_SAME_WALLPAPER") {
|
|
|
|
return td_api::make_object<td_api::pushMessageContentChatSetBackground>(true);
|
|
|
|
}
|
2022-12-25 19:29:56 +01:00
|
|
|
if (key == "MESSAGE_SCREENSHOT_TAKEN") {
|
|
|
|
return td_api::make_object<td_api::pushMessageContentScreenshotTaken>();
|
|
|
|
}
|
2019-04-05 08:09:58 +02:00
|
|
|
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_STICKER") {
|
2019-04-09 22:39:41 +02:00
|
|
|
return td_api::make_object<td_api::pushMessageContentSticker>(
|
2023-06-24 22:53:50 +02:00
|
|
|
td->stickers_manager_->get_sticker_object(document.file_id), trim(arg), is_pinned);
|
2019-04-05 08:09:58 +02:00
|
|
|
}
|
2023-06-22 20:18:04 +02:00
|
|
|
if (key == "MESSAGE_STORY") {
|
|
|
|
return td_api::make_object<td_api::pushMessageContentStory>(is_pinned);
|
|
|
|
}
|
2022-12-25 19:29:56 +01:00
|
|
|
if (key == "MESSAGE_SUGGEST_PHOTO") {
|
|
|
|
return td_api::make_object<td_api::pushMessageContentSuggestProfilePhoto>();
|
|
|
|
}
|
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
|
|
|
return td_api::make_object<td_api::pushMessageContentVideo>(
|
2023-06-24 22:53:50 +02:00
|
|
|
td->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
|
|
|
return td_api::make_object<td_api::pushMessageContentVideoNote>(
|
2023-06-24 22:53:50 +02:00
|
|
|
td->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
|
|
|
return td_api::make_object<td_api::pushMessageContentVoiceNote>(
|
2023-06-24 22:53:50 +02:00
|
|
|
td->voice_notes_manager_->get_voice_note_object(document.file_id), is_pinned);
|
2019-04-05 08:09:58 +02:00
|
|
|
}
|
|
|
|
break;
|
2023-04-10 14:14:03 +02:00
|
|
|
case 'W':
|
|
|
|
if (key == "MESSAGE_WALLPAPER") {
|
|
|
|
return td_api::make_object<td_api::pushMessageContentChatSetBackground>(false);
|
|
|
|
}
|
|
|
|
break;
|
2019-04-05 08:09:58 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
2023-06-24 23:09:48 +02:00
|
|
|
td_api::object_ptr<td_api::NotificationType> get_notification_type_object(Td *td, DialogId) const final {
|
2023-06-24 22:53:50 +02:00
|
|
|
auto sender = get_message_sender_object(td, 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_,
|
2023-06-24 22:53:50 +02:00
|
|
|
get_push_message_content_object(td, 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
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-06-16 17:54:50 +02:00
|
|
|
unique_ptr<NotificationType> create_new_message_notification(MessageId message_id, bool show_preview) {
|
|
|
|
return make_unique<NotificationTypeMessage>(message_id, show_preview);
|
2018-11-09 23:56:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|