Add document contents to pushMessageContent.
GitOrigin-RevId: 5baa4853f4e47d9f50f23ca74ebbed0369f17558
This commit is contained in:
parent
46a0b0036d
commit
082ba9e020
@ -1938,8 +1938,11 @@ checkChatUsernameResultPublicGroupsUnavailable = CheckChatUsernameResult;
|
||||
//@description A general message with hidden content @is_pinned True, if the message is a pinned message with the specified content
|
||||
pushMessageContentHidden is_pinned:Bool = PushMessageContent;
|
||||
|
||||
//@description An animation message (GIF-style) @is_pinned True, if the message is a pinned message with the specified content
|
||||
pushMessageContentAnimation is_pinned:Bool = PushMessageContent;
|
||||
//@description An animation message (GIF-style) @animation Message content; may be null @caption Animation caption @is_pinned True, if the message is a pinned message with the specified content
|
||||
pushMessageContentAnimation animation:animation caption:string is_pinned:Bool = PushMessageContent;
|
||||
|
||||
//@description An audio message @audio Message content; may be null @caption Audio caption @is_pinned True, if the message is a pinned message with the specified content
|
||||
pushMessageContentAudio audio:audio caption:string is_pinned:Bool = PushMessageContent;
|
||||
|
||||
//@description A message with a user contact @name Contact's name @is_pinned True, if the message is a pinned message with the specified content
|
||||
pushMessageContentContact name:string is_pinned:Bool = PushMessageContent;
|
||||
@ -1947,8 +1950,8 @@ pushMessageContentContact name:string is_pinned:Bool = PushMessageContent;
|
||||
//@description A contact has registered with Telegram
|
||||
pushMessageContentContactRegistered = PushMessageContent;
|
||||
|
||||
//@description A document message (general file) @is_pinned True, if the message is a pinned message with the specified content
|
||||
pushMessageContentDocument is_pinned:Bool = PushMessageContent;
|
||||
//@description A document message (a general file) @document Message content; may be null @caption Document caption @is_pinned True, if the message is a pinned message with the specified content
|
||||
pushMessageContentDocument document:document caption:string is_pinned:Bool = PushMessageContent;
|
||||
|
||||
//@description A message with a game @title Game title @is_pinned True, if the message is a pinned message with the specified content
|
||||
pushMessageContentGame title:string is_pinned:Bool = PushMessageContent;
|
||||
@ -1971,20 +1974,20 @@ pushMessageContentPoll question:string is_pinned:Bool = PushMessageContent;
|
||||
//@description A screenshot of a message in the chat has been taken
|
||||
pushMessageContentScreenshotTaken = PushMessageContent;
|
||||
|
||||
//@description A message with a sticker @emoji Emoji corresponding to the sticker; may be empty @is_pinned True, if the message is a pinned message with the specified content
|
||||
pushMessageContentSticker emoji:string is_pinned:Bool = PushMessageContent;
|
||||
//@description A message with a sticker @sticker Message content; may be null @emoji Emoji corresponding to the sticker; may be empty @is_pinned True, if the message is a pinned message with the specified content
|
||||
pushMessageContentSticker sticker:sticker emoji:string is_pinned:Bool = PushMessageContent;
|
||||
|
||||
//@description A text message @text Message text @is_pinned True, if the message is a pinned message with the specified content
|
||||
pushMessageContentText text:string is_pinned:Bool = PushMessageContent;
|
||||
|
||||
//@description A video message @is_secret True, if the video is secret @is_pinned True, if the message is a pinned message with the specified content
|
||||
pushMessageContentVideo is_secret:Bool is_pinned:Bool = PushMessageContent;
|
||||
//@description A video message @video Message content; may be null @caption Video caption @is_secret True, if the video is secret @is_pinned True, if the message is a pinned message with the specified content
|
||||
pushMessageContentVideo video:video caption:string is_secret:Bool is_pinned:Bool = PushMessageContent;
|
||||
|
||||
//@description A video note message @is_pinned True, if the message is a pinned message with the specified content
|
||||
pushMessageContentVideoNote is_pinned:Bool = PushMessageContent;
|
||||
//@description A video note message @video_note Message content; may be null @is_pinned True, if the message is a pinned message with the specified content
|
||||
pushMessageContentVideoNote video_note:videoNote is_pinned:Bool = PushMessageContent;
|
||||
|
||||
//@description A voice note message @is_pinned True, if the message is a pinned message with the specified content
|
||||
pushMessageContentVoiceNote is_pinned:Bool = PushMessageContent;
|
||||
//@description A voice note message @voice_note Message content; may be null @caption Voice note caption @is_pinned True, if the message is a pinned message with the specified content
|
||||
pushMessageContentVoiceNote voice_note:voiceNote caption:string is_pinned:Bool = PushMessageContent;
|
||||
|
||||
//@description A newly created basic group
|
||||
pushMessageContentBasicGroupChatCreate = PushMessageContent;
|
||||
|
Binary file not shown.
@ -23,6 +23,10 @@ struct Document {
|
||||
Document() = default;
|
||||
Document(Type type, FileId file_id) : type(type), file_id(file_id) {
|
||||
}
|
||||
|
||||
bool empty() const {
|
||||
return type == Type::Unknown;
|
||||
}
|
||||
};
|
||||
|
||||
StringBuilder &operator<<(StringBuilder &string_builder, const Document &document);
|
||||
|
@ -225,7 +225,7 @@ Document DocumentsManager::on_get_document(RemoteDocument remote_document, Dialo
|
||||
file_type = FileType::Encrypted;
|
||||
encryption_key = FileEncryptionKey{document->key_.as_slice(), document->iv_.as_slice()};
|
||||
if (encryption_key.empty()) {
|
||||
return {Document::Type::Unknown, FileId()};
|
||||
return {};
|
||||
}
|
||||
|
||||
if (document_type != Document::Type::VoiceNote) {
|
||||
@ -246,7 +246,7 @@ Document DocumentsManager::on_get_document(RemoteDocument remote_document, Dialo
|
||||
auto r_http_url = parse_url(web_document->url_);
|
||||
if (r_http_url.is_error()) {
|
||||
LOG(ERROR) << "Can't parse URL " << web_document->url_;
|
||||
return {Document::Type::Unknown, FileId()};
|
||||
return {};
|
||||
}
|
||||
auto http_url = r_http_url.move_as_ok();
|
||||
|
||||
@ -263,7 +263,7 @@ Document DocumentsManager::on_get_document(RemoteDocument remote_document, Dialo
|
||||
|
||||
if (web_document->url_.find('.') == string::npos) {
|
||||
LOG(ERROR) << "Receive invalid URL " << web_document->url_;
|
||||
return {Document::Type::Unknown, FileId()};
|
||||
return {};
|
||||
}
|
||||
|
||||
url = std::move(web_document->url_);
|
||||
@ -280,7 +280,7 @@ Document DocumentsManager::on_get_document(RemoteDocument remote_document, Dialo
|
||||
LOG(DEBUG) << "Receive document with id = " << id << " of type " << static_cast<int32>(document_type);
|
||||
if (!is_web && !DcId::is_valid(dc_id)) {
|
||||
LOG(ERROR) << "Wrong dc_id = " << dc_id;
|
||||
return {Document::Type::Unknown, FileId()};
|
||||
return {};
|
||||
}
|
||||
|
||||
auto suggested_file_name = file_name;
|
||||
@ -308,7 +308,7 @@ Document DocumentsManager::on_get_document(RemoteDocument remote_document, Dialo
|
||||
auto r_file_id = td_->file_manager_->from_persistent_id(url, file_type);
|
||||
if (r_file_id.is_error()) {
|
||||
LOG(ERROR) << "Can't register URL: " << r_file_id.error();
|
||||
return {Document::Type::Unknown, FileId()};
|
||||
return {};
|
||||
}
|
||||
file_id = r_file_id.move_as_ok();
|
||||
}
|
||||
|
@ -3495,7 +3495,7 @@ static tl_object_ptr<ToT> secret_to_telegram(FromT &from) {
|
||||
static unique_ptr<MessageContent> get_document_message_content(Document &&parsed_document, FormattedText &&caption,
|
||||
bool is_opened) {
|
||||
auto file_id = parsed_document.file_id;
|
||||
if (parsed_document.type != Document::Type::Unknown) {
|
||||
if (!parsed_document.empty()) {
|
||||
CHECK(file_id.is_valid());
|
||||
}
|
||||
switch (parsed_document.type) {
|
||||
|
@ -22186,7 +22186,7 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
|
||||
if (!message->from_database) {
|
||||
LOG(ERROR) << "Ignore " << message_id << " in " << dialog_id << " received not through update from " << source
|
||||
<< ". Last new is " << d->last_new_message_id << ", channel difference "
|
||||
<< debug_channel_difference_dialog_ << to_string(get_message_object(dialog_id, message.get()));
|
||||
<< debug_channel_difference_dialog_ << " " << to_string(get_message_object(dialog_id, message.get()));
|
||||
dump_debug_message_op(d, 3);
|
||||
if (dialog_id.get_type() == DialogType::Channel && have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
channel_get_difference_retry_timeout_.add_timeout_in(dialog_id.get(), 0.001);
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/DeviceTokenManager.h"
|
||||
#include "td/telegram/Document.h"
|
||||
#include "td/telegram/Document.hpp"
|
||||
#include "td/telegram/DocumentsManager.h"
|
||||
#include "td/telegram/files/FileManager.h"
|
||||
#include "td/telegram/Global.h"
|
||||
@ -3170,7 +3171,7 @@ Status NotificationManager::process_push_notification_payload(string payload, Pr
|
||||
}
|
||||
TRY_RESULT(ph, get_json_object_field(mtpeer.get_object(), "ph", JsonValue::Type::Object));
|
||||
if (ph.type() != JsonValue::Type::Null) {
|
||||
// TODO parse photo
|
||||
// TODO parse sender photo
|
||||
}
|
||||
}
|
||||
|
||||
@ -3191,6 +3192,7 @@ Status NotificationManager::process_push_notification_payload(string payload, Pr
|
||||
|
||||
Photo attached_photo;
|
||||
attached_photo.id = -2;
|
||||
Document attached_document;
|
||||
if (has_json_object_field(custom, "attachb64")) {
|
||||
TRY_RESULT(attachb64, get_json_object_string_field(custom, "attachb64", false));
|
||||
TRY_RESULT(attach, base64url_decode(attachb64));
|
||||
@ -3237,21 +3239,45 @@ Status NotificationManager::process_push_notification_payload(string payload, Pr
|
||||
}
|
||||
break;
|
||||
case telegram_api::document::ID: {
|
||||
auto parsed_document = td_->documents_manager_->on_get_document(
|
||||
telegram_api::move_object_as<telegram_api::document>(result), dialog_id);
|
||||
switch (parsed_document.type) {
|
||||
case Document::Type::Animation:
|
||||
case Document::Type::Audio:
|
||||
case Document::Type::General:
|
||||
case Document::Type::Sticker:
|
||||
case Document::Type::Unknown:
|
||||
case Document::Type::Video:
|
||||
case Document::Type::VideoNote:
|
||||
case Document::Type::VoiceNote:
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return Status::Error("Unreachable");
|
||||
if (ends_with(loc_key, "MESSAGE_ANIMATION") || ends_with(loc_key, "MESSAGE_AUDIO") ||
|
||||
ends_with(loc_key, "MESSAGE_DOCUMENT") || ends_with(loc_key, "MESSAGE_STICKER") ||
|
||||
ends_with(loc_key, "MESSAGE_VIDEO") || ends_with(loc_key, "MESSAGE_VIDEO_NOTE") ||
|
||||
ends_with(loc_key, "MESSAGE_VOICE_NOTE") || ends_with(loc_key, "MESSAGE_TEXT")) {
|
||||
attached_document = td_->documents_manager_->on_get_document(
|
||||
telegram_api::move_object_as<telegram_api::document>(result), dialog_id);
|
||||
if (!attached_document.empty()) {
|
||||
if (ends_with(loc_key, "_NOTE")) {
|
||||
loc_key.resize(loc_key.rfind('_'));
|
||||
}
|
||||
loc_key.resize(loc_key.rfind('_') + 1);
|
||||
|
||||
auto type = [attached_document] {
|
||||
switch (attached_document.type) {
|
||||
case Document::Type::Animation:
|
||||
return "ANIMATION";
|
||||
case Document::Type::Audio:
|
||||
return "AUDIO";
|
||||
case Document::Type::General:
|
||||
return "DOCUMENT";
|
||||
case Document::Type::Sticker:
|
||||
return "STICKER";
|
||||
case Document::Type::Video:
|
||||
return "VIDEO";
|
||||
case Document::Type::VideoNote:
|
||||
return "VIDEO_NOTE";
|
||||
case Document::Type::VoiceNote:
|
||||
return "VOICE_NOTE";
|
||||
case Document::Type::Unknown:
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return "UNREACHABLE";
|
||||
}
|
||||
}();
|
||||
|
||||
loc_key += type;
|
||||
}
|
||||
} else {
|
||||
LOG(ERROR) << "Receive attached document for " << loc_key;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -3270,11 +3296,13 @@ Status NotificationManager::process_push_notification_payload(string payload, Pr
|
||||
return Status::Error("Receive wrong edit date");
|
||||
}
|
||||
edit_message_push_notification(dialog_id, MessageId(server_message_id), edit_date, std::move(loc_key),
|
||||
std::move(arg), std::move(attached_photo), 0, std::move(promise));
|
||||
std::move(arg), std::move(attached_photo), std::move(attached_document), 0,
|
||||
std::move(promise));
|
||||
} else {
|
||||
add_message_push_notification(dialog_id, MessageId(server_message_id), random_id, sender_user_id,
|
||||
std::move(sender_name), sent_date, contains_mention, is_silent, std::move(loc_key),
|
||||
std::move(arg), std::move(attached_photo), NotificationId(), 0, std::move(promise));
|
||||
std::move(arg), std::move(attached_photo), std::move(attached_document),
|
||||
NotificationId(), 0, std::move(promise));
|
||||
}
|
||||
return Status::OK();
|
||||
}
|
||||
@ -3292,6 +3320,7 @@ class NotificationManager::AddMessagePushNotificationLogEvent {
|
||||
string loc_key_;
|
||||
string arg_;
|
||||
Photo photo_;
|
||||
Document document_;
|
||||
NotificationId notification_id_;
|
||||
|
||||
template <class StorerT>
|
||||
@ -3302,6 +3331,7 @@ class NotificationManager::AddMessagePushNotificationLogEvent {
|
||||
bool has_sender_name = !sender_name_.empty();
|
||||
bool has_arg = !arg_.empty();
|
||||
bool has_photo = photo_.id != -2;
|
||||
bool has_document = !document_.empty();
|
||||
BEGIN_STORE_FLAGS();
|
||||
STORE_FLAG(contains_mention_);
|
||||
STORE_FLAG(is_silent_);
|
||||
@ -3311,6 +3341,7 @@ class NotificationManager::AddMessagePushNotificationLogEvent {
|
||||
STORE_FLAG(has_sender_name);
|
||||
STORE_FLAG(has_arg);
|
||||
STORE_FLAG(has_photo);
|
||||
STORE_FLAG(has_document);
|
||||
END_STORE_FLAGS();
|
||||
td::store(dialog_id_, storer);
|
||||
if (has_message_id) {
|
||||
@ -3333,6 +3364,9 @@ class NotificationManager::AddMessagePushNotificationLogEvent {
|
||||
if (has_photo) {
|
||||
td::store(photo_, storer);
|
||||
}
|
||||
if (has_document) {
|
||||
td::store(document_, storer);
|
||||
}
|
||||
td::store(notification_id_, storer);
|
||||
}
|
||||
|
||||
@ -3344,6 +3378,7 @@ class NotificationManager::AddMessagePushNotificationLogEvent {
|
||||
bool has_sender_name;
|
||||
bool has_arg;
|
||||
bool has_photo;
|
||||
bool has_document;
|
||||
BEGIN_PARSE_FLAGS();
|
||||
PARSE_FLAG(contains_mention_);
|
||||
PARSE_FLAG(is_silent_);
|
||||
@ -3353,6 +3388,7 @@ class NotificationManager::AddMessagePushNotificationLogEvent {
|
||||
PARSE_FLAG(has_sender_name);
|
||||
PARSE_FLAG(has_arg);
|
||||
PARSE_FLAG(has_photo);
|
||||
PARSE_FLAG(has_document);
|
||||
END_PARSE_FLAGS();
|
||||
td::parse(dialog_id_, parser);
|
||||
if (has_message_id) {
|
||||
@ -3379,6 +3415,9 @@ class NotificationManager::AddMessagePushNotificationLogEvent {
|
||||
} else {
|
||||
photo_.id = -2;
|
||||
}
|
||||
if (has_document) {
|
||||
td::parse(document_, parser);
|
||||
}
|
||||
td::parse(notification_id_, parser);
|
||||
}
|
||||
};
|
||||
@ -3386,8 +3425,9 @@ class NotificationManager::AddMessagePushNotificationLogEvent {
|
||||
void NotificationManager::add_message_push_notification(DialogId dialog_id, MessageId message_id, int64 random_id,
|
||||
UserId sender_user_id, string sender_name, int32 date,
|
||||
bool contains_mention, bool is_silent, string loc_key,
|
||||
string arg, Photo photo, NotificationId notification_id,
|
||||
uint64 logevent_id, Promise<Unit> promise) {
|
||||
string arg, Photo photo, Document document,
|
||||
NotificationId notification_id, uint64 logevent_id,
|
||||
Promise<Unit> promise) {
|
||||
auto is_pinned = begins_with(loc_key, "PINNED_");
|
||||
auto r_info = td_->messages_manager_->get_message_push_notification_info(
|
||||
dialog_id, message_id, random_id, sender_user_id, date, contains_mention, is_pinned, logevent_id != 0);
|
||||
@ -3444,9 +3484,9 @@ void NotificationManager::add_message_push_notification(DialogId dialog_id, Mess
|
||||
}
|
||||
|
||||
if (logevent_id == 0 && G()->parameters().use_message_db) {
|
||||
AddMessagePushNotificationLogEvent logevent{dialog_id, message_id, random_id, sender_user_id, sender_name,
|
||||
date, contains_mention, is_silent, loc_key, arg,
|
||||
photo, notification_id};
|
||||
AddMessagePushNotificationLogEvent logevent{
|
||||
dialog_id, message_id, random_id, sender_user_id, sender_name, date, contains_mention,
|
||||
is_silent, loc_key, arg, photo, document, notification_id};
|
||||
auto storer = LogEventStorerImpl<AddMessagePushNotificationLogEvent>(logevent);
|
||||
logevent_id = binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::AddMessagePushNotification, storer);
|
||||
}
|
||||
@ -3466,13 +3506,13 @@ void NotificationManager::add_message_push_notification(DialogId dialog_id, Mess
|
||||
auto settings_dialog_id = info.settings_dialog_id;
|
||||
VLOG(notifications) << "Add message push " << notification_id << " of type " << loc_key << " for " << message_id
|
||||
<< "/" << random_id << " in " << dialog_id << ", sent by " << sender_user_id << " at " << date
|
||||
<< " with arg " << arg << ", photo " << photo << " to " << group_id << " of type " << group_type
|
||||
<< " with settings from " << settings_dialog_id;
|
||||
<< " with arg " << arg << ", photo " << photo << " and document " << document << " to "
|
||||
<< group_id << " of type " << group_type << " with settings from " << settings_dialog_id;
|
||||
|
||||
add_notification(group_id, group_type, dialog_id, date, settings_dialog_id, is_silent, 0, notification_id,
|
||||
create_new_push_message_notification(sender_user_id, message_id, std::move(loc_key), std::move(arg),
|
||||
std::move(photo)),
|
||||
"add_push_notification");
|
||||
std::move(photo), std::move(document)),
|
||||
"add_message_push_notification");
|
||||
}
|
||||
|
||||
class NotificationManager::EditMessagePushNotificationLogEvent {
|
||||
@ -3483,16 +3523,19 @@ class NotificationManager::EditMessagePushNotificationLogEvent {
|
||||
string loc_key_;
|
||||
string arg_;
|
||||
Photo photo_;
|
||||
Document document_;
|
||||
|
||||
template <class StorerT>
|
||||
void store(StorerT &storer) const {
|
||||
bool has_message_id = message_id_.is_valid();
|
||||
bool has_arg = !arg_.empty();
|
||||
bool has_photo = photo_.id != -2;
|
||||
bool has_document = !document_.empty();
|
||||
BEGIN_STORE_FLAGS();
|
||||
STORE_FLAG(has_message_id);
|
||||
STORE_FLAG(has_arg);
|
||||
STORE_FLAG(has_photo);
|
||||
STORE_FLAG(has_document);
|
||||
END_STORE_FLAGS();
|
||||
td::store(dialog_id_, storer);
|
||||
if (has_message_id) {
|
||||
@ -3506,6 +3549,9 @@ class NotificationManager::EditMessagePushNotificationLogEvent {
|
||||
if (has_photo) {
|
||||
td::store(photo_, storer);
|
||||
}
|
||||
if (has_document) {
|
||||
td::store(document_, storer);
|
||||
}
|
||||
}
|
||||
|
||||
template <class ParserT>
|
||||
@ -3513,10 +3559,12 @@ class NotificationManager::EditMessagePushNotificationLogEvent {
|
||||
bool has_message_id;
|
||||
bool has_arg;
|
||||
bool has_photo;
|
||||
bool has_document;
|
||||
BEGIN_PARSE_FLAGS();
|
||||
PARSE_FLAG(has_message_id);
|
||||
PARSE_FLAG(has_arg);
|
||||
PARSE_FLAG(has_photo);
|
||||
PARSE_FLAG(has_document);
|
||||
END_PARSE_FLAGS();
|
||||
td::parse(dialog_id_, parser);
|
||||
if (has_message_id) {
|
||||
@ -3532,12 +3580,15 @@ class NotificationManager::EditMessagePushNotificationLogEvent {
|
||||
} else {
|
||||
photo_.id = -2;
|
||||
}
|
||||
if (has_document) {
|
||||
td::parse(document_, parser);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void NotificationManager::edit_message_push_notification(DialogId dialog_id, MessageId message_id, int32 edit_date,
|
||||
string loc_key, string arg, Photo photo, uint64 logevent_id,
|
||||
Promise<Unit> promise) {
|
||||
string loc_key, string arg, Photo photo, Document document,
|
||||
uint64 logevent_id, Promise<Unit> promise) {
|
||||
if (is_disabled() || max_notification_group_count_ == 0) {
|
||||
CHECK(logevent_id == 0);
|
||||
return promise.set_error(Status::Error(200, "Immediate success"));
|
||||
@ -3557,7 +3608,7 @@ void NotificationManager::edit_message_push_notification(DialogId dialog_id, Mes
|
||||
CHECK(notification_id.is_valid());
|
||||
|
||||
if (logevent_id == 0 && G()->parameters().use_message_db) {
|
||||
EditMessagePushNotificationLogEvent logevent{dialog_id, message_id, edit_date, loc_key, arg, photo};
|
||||
EditMessagePushNotificationLogEvent logevent{dialog_id, message_id, edit_date, loc_key, arg, photo, document};
|
||||
auto storer = LogEventStorerImpl<EditMessagePushNotificationLogEvent>(logevent);
|
||||
auto &cur_logevent_id = temporary_edit_notification_logevent_ids_[notification_id];
|
||||
if (cur_logevent_id == 0) {
|
||||
@ -3579,7 +3630,7 @@ void NotificationManager::edit_message_push_notification(DialogId dialog_id, Mes
|
||||
|
||||
edit_notification(group_id, notification_id,
|
||||
create_new_push_message_notification(sender_user_id, message_id, std::move(loc_key), std::move(arg),
|
||||
std::move(photo)));
|
||||
std::move(photo), std::move(document)));
|
||||
}
|
||||
|
||||
Result<int64> NotificationManager::get_push_receiver_id(string payload) {
|
||||
@ -3905,7 +3956,7 @@ void NotificationManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
add_message_push_notification(
|
||||
log_event.dialog_id_, log_event.message_id_, log_event.random_id_, log_event.sender_user_id_,
|
||||
log_event.sender_name_, log_event.date_, log_event.contains_mention_, true, log_event.loc_key_,
|
||||
log_event.arg_, log_event.photo_, log_event.notification_id_, event.id_,
|
||||
log_event.arg_, log_event.photo_, log_event.document_, log_event.notification_id_, event.id_,
|
||||
PromiseCreator::lambda([](Result<Unit> result) {
|
||||
if (result.is_error()) {
|
||||
LOG(ERROR) << "Receive error " << result.error() << ", while processing message push notification";
|
||||
@ -3920,7 +3971,7 @@ void NotificationManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
|
||||
edit_message_push_notification(
|
||||
log_event.dialog_id_, log_event.message_id_, log_event.edit_date_, log_event.loc_key_, log_event.arg_,
|
||||
log_event.photo_, event.id_, PromiseCreator::lambda([](Result<Unit> result) {
|
||||
log_event.photo_, log_event.document_, event.id_, PromiseCreator::lambda([](Result<Unit> result) {
|
||||
if (result.is_error()) {
|
||||
LOG(ERROR) << "Receive error " << result.error() << ", while processing edit message push notification";
|
||||
}
|
||||
|
@ -295,11 +295,12 @@ class NotificationManager : public Actor {
|
||||
|
||||
void add_message_push_notification(DialogId dialog_id, MessageId message_id, int64 random_id, UserId sender_user_id,
|
||||
string sender_name, int32 date, bool contains_mention, bool is_silent,
|
||||
string loc_key, string arg, Photo photo, NotificationId notification_id,
|
||||
uint64 logevent_id, Promise<Unit> promise);
|
||||
string loc_key, string arg, Photo photo, Document document,
|
||||
NotificationId notification_id, uint64 logevent_id, Promise<Unit> promise);
|
||||
|
||||
void edit_message_push_notification(DialogId dialog_id, MessageId message_id, int32 edit_date, string loc_key,
|
||||
string arg, Photo photo, uint64 logevent_id, Promise<Unit> promise);
|
||||
string arg, Photo photo, Document document, uint64 logevent_id,
|
||||
Promise<Unit> promise);
|
||||
|
||||
void after_get_difference_impl();
|
||||
|
||||
|
@ -6,10 +6,17 @@
|
||||
//
|
||||
#include "td/telegram/NotificationType.h"
|
||||
|
||||
#include "td/telegram/AnimationsManager.h"
|
||||
#include "td/telegram/AudiosManager.h"
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/DocumentsManager.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/MessagesManager.h"
|
||||
#include "td/telegram/StickersManager.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/VideosManager.h"
|
||||
#include "td/telegram/VideoNotesManager.h"
|
||||
#include "td/telegram/VoiceNotesManager.h"
|
||||
|
||||
#include "td/utils/misc.h"
|
||||
#include "td/utils/Slice.h"
|
||||
@ -128,7 +135,8 @@ class NotificationTypePushMessage : public NotificationType {
|
||||
}
|
||||
|
||||
static td_api::object_ptr<td_api::PushMessageContent> get_push_message_content_object(Slice key, const string &arg,
|
||||
const Photo &photo) {
|
||||
const Photo &photo,
|
||||
const Document &document) {
|
||||
bool is_pinned = false;
|
||||
if (begins_with(key, "PINNED_")) {
|
||||
is_pinned = true;
|
||||
@ -144,7 +152,14 @@ class NotificationTypePushMessage : public NotificationType {
|
||||
switch (key[8]) {
|
||||
case 'A':
|
||||
if (key == "MESSAGE_ANIMATION") {
|
||||
return td_api::make_object<td_api::pushMessageContentAnimation>(is_pinned);
|
||||
auto animations_manager = G()->td().get_actor_unsafe()->animations_manager_.get();
|
||||
return td_api::make_object<td_api::pushMessageContentAnimation>(
|
||||
animations_manager->get_animation_object(document.file_id, "MESSAGE_ANIMATION"), arg, is_pinned);
|
||||
}
|
||||
if (key == "MESSAGE_AUDIO") {
|
||||
auto audios_manager = G()->td().get_actor_unsafe()->audios_manager_.get();
|
||||
return td_api::make_object<td_api::pushMessageContentAudio>(
|
||||
audios_manager->get_audio_object(document.file_id), arg, is_pinned);
|
||||
}
|
||||
break;
|
||||
case 'B':
|
||||
@ -189,7 +204,9 @@ class NotificationTypePushMessage : public NotificationType {
|
||||
break;
|
||||
case 'D':
|
||||
if (key == "MESSAGE_DOCUMENT") {
|
||||
return td_api::make_object<td_api::pushMessageContentDocument>(is_pinned);
|
||||
auto documents_manager = G()->td().get_actor_unsafe()->documents_manager_.get();
|
||||
return td_api::make_object<td_api::pushMessageContentDocument>(
|
||||
documents_manager->get_document_object(document.file_id), arg, is_pinned);
|
||||
}
|
||||
break;
|
||||
case 'F':
|
||||
@ -243,13 +260,15 @@ class NotificationTypePushMessage : public NotificationType {
|
||||
return td_api::make_object<td_api::pushMessageContentPhoto>(nullptr, arg, true, false);
|
||||
}
|
||||
if (key == "MESSAGE_SECRET_VIDEO") {
|
||||
return td_api::make_object<td_api::pushMessageContentVideo>(true, false);
|
||||
return td_api::make_object<td_api::pushMessageContentVideo>(nullptr, arg, true, false);
|
||||
}
|
||||
if (key == "MESSAGE_SCREENSHOT_TAKEN") {
|
||||
return td_api::make_object<td_api::pushMessageContentScreenshotTaken>();
|
||||
}
|
||||
if (key == "MESSAGE_STICKER") {
|
||||
return td_api::make_object<td_api::pushMessageContentSticker>(arg, is_pinned);
|
||||
auto stickers_manager = G()->td().get_actor_unsafe()->stickers_manager_.get();
|
||||
return td_api::make_object<td_api::pushMessageContentSticker>(
|
||||
stickers_manager->get_sticker_object(document.file_id), arg, is_pinned);
|
||||
}
|
||||
break;
|
||||
case 'T':
|
||||
@ -259,16 +278,22 @@ class NotificationTypePushMessage : public NotificationType {
|
||||
break;
|
||||
case 'V':
|
||||
if (key == "MESSAGE_VIDEO") {
|
||||
return td_api::make_object<td_api::pushMessageContentVideo>(false, is_pinned);
|
||||
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);
|
||||
}
|
||||
if (key == "MESSAGE_VIDEO_NOTE") {
|
||||
return td_api::make_object<td_api::pushMessageContentVideoNote>(is_pinned);
|
||||
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);
|
||||
}
|
||||
if (key == "MESSAGE_VIDEOS") {
|
||||
return td_api::make_object<td_api::pushMessageContentMediaAlbum>(to_integer<int32>(arg), false, true);
|
||||
}
|
||||
if (key == "MESSAGE_VOICE_NOTE") {
|
||||
return td_api::make_object<td_api::pushMessageContentVoiceNote>(is_pinned);
|
||||
auto voice_notes_manager = G()->td().get_actor_unsafe()->voice_notes_manager_.get();
|
||||
return td_api::make_object<td_api::pushMessageContentVoiceNote>(
|
||||
voice_notes_manager->get_voice_note_object(document.file_id), arg, is_pinned);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -281,12 +306,12 @@ class NotificationTypePushMessage : public NotificationType {
|
||||
auto sender_user_id = G()->td().get_actor_unsafe()->contacts_manager_->get_user_id_object(
|
||||
sender_user_id_, "get_notification_type_object");
|
||||
return td_api::make_object<td_api::notificationTypeNewPushMessage>(
|
||||
message_id_.get(), sender_user_id, get_push_message_content_object(key_, arg_, photo_));
|
||||
message_id_.get(), sender_user_id, get_push_message_content_object(key_, arg_, photo_, document_));
|
||||
}
|
||||
|
||||
StringBuilder &to_string_builder(StringBuilder &string_builder) const override {
|
||||
return string_builder << "NewPushMessageNotification[" << sender_user_id_ << ", " << message_id_ << ", " << key_
|
||||
<< ", " << arg_ << ", " << photo_ << ']';
|
||||
<< ", " << arg_ << ", " << photo_ << ", " << document_ << ']';
|
||||
}
|
||||
/*
|
||||
Type get_type() const override {
|
||||
@ -298,14 +323,17 @@ class NotificationTypePushMessage : public NotificationType {
|
||||
string key_;
|
||||
string arg_;
|
||||
Photo photo_;
|
||||
Document document_;
|
||||
|
||||
public:
|
||||
NotificationTypePushMessage(UserId sender_user_id, MessageId message_id, string key, string arg, Photo photo)
|
||||
NotificationTypePushMessage(UserId sender_user_id, MessageId message_id, string key, string arg, Photo photo,
|
||||
Document document)
|
||||
: sender_user_id_(std::move(sender_user_id))
|
||||
, message_id_(message_id)
|
||||
, key_(std::move(key))
|
||||
, arg_(std::move(arg))
|
||||
, photo_(std::move(photo)) {
|
||||
, photo_(std::move(photo))
|
||||
, document_(std::move(document)) {
|
||||
}
|
||||
};
|
||||
|
||||
@ -322,9 +350,10 @@ unique_ptr<NotificationType> create_new_call_notification(CallId call_id) {
|
||||
}
|
||||
|
||||
unique_ptr<NotificationType> create_new_push_message_notification(UserId sender_user_id, MessageId message_id,
|
||||
string key, string arg, Photo photo) {
|
||||
string key, string arg, Photo photo,
|
||||
Document document) {
|
||||
return td::make_unique<NotificationTypePushMessage>(sender_user_id, message_id, std::move(key), std::move(arg),
|
||||
std::move(photo));
|
||||
std::move(photo), std::move(document));
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "td/telegram/CallId.h"
|
||||
#include "td/telegram/DialogId.h"
|
||||
#include "td/telegram/Document.h"
|
||||
#include "td/telegram/MessageId.h"
|
||||
#include "td/telegram/Photo.h"
|
||||
#include "td/telegram/td_api.h"
|
||||
@ -63,6 +64,7 @@ unique_ptr<NotificationType> create_new_secret_chat_notification();
|
||||
unique_ptr<NotificationType> create_new_call_notification(CallId call_id);
|
||||
|
||||
unique_ptr<NotificationType> create_new_push_message_notification(UserId sender_user_id, MessageId message_id,
|
||||
string key, string arg, Photo photo);
|
||||
string key, string arg, Photo photo,
|
||||
Document document);
|
||||
|
||||
} // namespace td
|
||||
|
@ -230,7 +230,7 @@ class WebPagesManager::WebPage {
|
||||
bool has_embed_dimensions = has_embed && embed_dimensions != Dimensions();
|
||||
bool has_duration = duration > 0;
|
||||
bool has_author = !author.empty();
|
||||
bool has_document = document.type != Document::Type::Unknown;
|
||||
bool has_document = !document.empty();
|
||||
bool has_instant_view = !instant_view.is_empty;
|
||||
bool is_instant_view_v2 = instant_view.is_v2;
|
||||
bool has_no_hash = true;
|
||||
|
Reference in New Issue
Block a user