diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index e54ea4b8..6bda440c 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -2303,8 +2303,9 @@ notificationTypeNewCall call_id:int32 = NotificationType; //@message_id The message identifier. The message will not be available in the chat history, but the ID can be used in viewMessages and as reply_to_message_id //@sender_user_id Sender of the message; 0 if unknown. Corresponding user may be inaccessible //@sender_name Name of the sender; can be different from the name of the sender user +//@is_outgoing True, if the message is outgoing //@content Push message content -notificationTypeNewPushMessage message_id:int53 sender_user_id:int32 sender_name:string content:PushMessageContent = NotificationType; +notificationTypeNewPushMessage message_id:int53 sender_user_id:int32 sender_name:string is_outgoing:Bool content:PushMessageContent = NotificationType; //@class NotificationGroupType @description Describes the type of notifications in a notification group diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index cf3d05b0..f8711a96 100644 Binary files a/td/generate/scheme/td_api.tlo and b/td/generate/scheme/td_api.tlo differ diff --git a/td/telegram/NotificationManager.cpp b/td/telegram/NotificationManager.cpp index 7e0ef809..327c9fee 100644 --- a/td/telegram/NotificationManager.cpp +++ b/td/telegram/NotificationManager.cpp @@ -3592,11 +3592,13 @@ void NotificationManager::add_message_push_notification( auto group_id = info.group_id; CHECK(group_id.is_valid()); + bool is_outgoing = + sender_user_id.is_valid() ? td_->contacts_manager_->get_my_id() == sender_user_id : is_from_scheduled; if (logevent_id != 0) { VLOG(notifications) << "Register temporary " << notification_id << " with logevent " << logevent_id; temporary_notification_logevent_ids_[notification_id] = logevent_id; temporary_notifications_[FullMessageId(dialog_id, message_id)] = {group_id, notification_id, sender_user_id, - sender_name}; + sender_name, is_outgoing}; temporary_notification_message_ids_[notification_id] = FullMessageId(dialog_id, message_id); } push_notification_promises_[notification_id].push_back(std::move(promise)); @@ -3609,11 +3611,11 @@ void NotificationManager::add_message_push_notification( << " 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, initial_is_silent, is_silent, 0, - notification_id, - create_new_push_message_notification(sender_user_id, sender_name, message_id, std::move(loc_key), - std::move(arg), std::move(photo), std::move(document)), - "add_message_push_notification"); + add_notification( + group_id, group_type, dialog_id, date, settings_dialog_id, initial_is_silent, is_silent, 0, notification_id, + create_new_push_message_notification(sender_user_id, sender_name, is_outgoing, message_id, std::move(loc_key), + std::move(arg), std::move(photo), std::move(document)), + "add_message_push_notification"); } class NotificationManager::EditMessagePushNotificationLogEvent { @@ -3706,6 +3708,7 @@ void NotificationManager::edit_message_push_notification(DialogId dialog_id, Mes auto notification_id = it->second.notification_id; auto sender_user_id = it->second.sender_user_id; auto sender_name = it->second.sender_name; + auto is_outgoing = it->second.is_outgoing; CHECK(group_id.is_valid()); CHECK(notification_id.is_valid()); @@ -3732,8 +3735,8 @@ void NotificationManager::edit_message_push_notification(DialogId dialog_id, Mes edit_notification( group_id, notification_id, - create_new_push_message_notification(sender_user_id, std::move(sender_name), message_id, std::move(loc_key), - std::move(arg), std::move(photo), std::move(document))); + create_new_push_message_notification(sender_user_id, std::move(sender_name), is_outgoing, message_id, + std::move(loc_key), std::move(arg), std::move(photo), std::move(document))); } Result NotificationManager::get_push_receiver_id(string payload) { diff --git a/td/telegram/NotificationManager.h b/td/telegram/NotificationManager.h index 89ac66f5..6bc26802 100644 --- a/td/telegram/NotificationManager.h +++ b/td/telegram/NotificationManager.h @@ -389,6 +389,7 @@ class NotificationManager : public Actor { NotificationId notification_id; UserId sender_user_id; string sender_name; + bool is_outgoing; }; std::unordered_map temporary_notifications_; std::unordered_map temporary_notification_message_ids_; diff --git a/td/telegram/NotificationType.cpp b/td/telegram/NotificationType.cpp index eeff7175..39dfb172 100644 --- a/td/telegram/NotificationType.cpp +++ b/td/telegram/NotificationType.cpp @@ -321,7 +321,7 @@ 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( - message_id_.get(), sender_user_id, sender_name_, + message_id_.get(), sender_user_id, sender_name_, is_outgoing_, get_push_message_content_object(key_, arg_, photo_, document_)); } @@ -337,17 +337,19 @@ class NotificationTypePushMessage : public NotificationType { string arg_; Photo photo_; Document document_; + bool is_outgoing_; public: - NotificationTypePushMessage(UserId sender_user_id, string sender_name, MessageId message_id, string key, string arg, - Photo photo, Document document) + NotificationTypePushMessage(UserId sender_user_id, string sender_name, bool is_outgoing, MessageId message_id, + string key, string arg, Photo photo, Document document) : sender_user_id_(std::move(sender_user_id)) , message_id_(message_id) , sender_name_(std::move(sender_name)) , key_(std::move(key)) , arg_(std::move(arg)) , photo_(std::move(photo)) - , document_(std::move(document)) { + , document_(std::move(document)) + , is_outgoing_(is_outgoing) { } }; @@ -364,9 +366,9 @@ unique_ptr create_new_call_notification(CallId call_id) { } unique_ptr create_new_push_message_notification(UserId sender_user_id, string sender_name, - MessageId message_id, string key, string arg, - Photo photo, Document document) { - return td::make_unique(sender_user_id, std::move(sender_name), message_id, + bool is_outgoing, MessageId message_id, string key, + string arg, Photo photo, Document document) { + return td::make_unique(sender_user_id, std::move(sender_name), is_outgoing, message_id, std::move(key), std::move(arg), std::move(photo), std::move(document)); } diff --git a/td/telegram/NotificationType.h b/td/telegram/NotificationType.h index 49018d33..5b49eb33 100644 --- a/td/telegram/NotificationType.h +++ b/td/telegram/NotificationType.h @@ -60,7 +60,7 @@ unique_ptr create_new_secret_chat_notification(); unique_ptr create_new_call_notification(CallId call_id); unique_ptr create_new_push_message_notification(UserId sender_user_id, string sender_name, - MessageId message_id, string key, string arg, - Photo photo, Document document); + bool is_outgoing, MessageId message_id, string key, + string arg, Photo photo, Document document); } // namespace td