Add notificationTypeNewPushMessage.is_outgoing.

GitOrigin-RevId: c7ef758bef2b49cd08cab73520c2814e039e2154
This commit is contained in:
levlam 2020-02-29 21:42:02 +03:00
parent 44b31537aa
commit c0c87e5560
6 changed files with 25 additions and 18 deletions

View File

@ -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

Binary file not shown.

View File

@ -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<int64> NotificationManager::get_push_receiver_id(string payload) {

View File

@ -389,6 +389,7 @@ class NotificationManager : public Actor {
NotificationId notification_id;
UserId sender_user_id;
string sender_name;
bool is_outgoing;
};
std::unordered_map<FullMessageId, TemporaryNotification, FullMessageIdHash> temporary_notifications_;
std::unordered_map<NotificationId, FullMessageId, NotificationIdHash> temporary_notification_message_ids_;

View File

@ -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<td_api::notificationTypeNewPushMessage>(
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<NotificationType> create_new_call_notification(CallId call_id) {
}
unique_ptr<NotificationType> 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<NotificationTypePushMessage>(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<NotificationTypePushMessage>(sender_user_id, std::move(sender_name), is_outgoing, message_id,
std::move(key), std::move(arg), std::move(photo),
std::move(document));
}

View File

@ -60,7 +60,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, 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