2018-11-26 18:05:06 +01:00
|
|
|
//
|
2022-01-01 01:35:39 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
|
2018-11-26 18:05:06 +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)
|
|
|
|
//
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "td/telegram/DialogId.h"
|
|
|
|
#include "td/telegram/NotificationId.h"
|
|
|
|
#include "td/telegram/NotificationType.h"
|
|
|
|
#include "td/telegram/td_api.h"
|
|
|
|
|
|
|
|
#include "td/utils/common.h"
|
|
|
|
#include "td/utils/StringBuilder.h"
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
|
|
|
class Notification {
|
|
|
|
public:
|
|
|
|
NotificationId notification_id;
|
|
|
|
int32 date = 0;
|
2022-04-15 17:36:24 +02:00
|
|
|
int64 ringtone_id = -1;
|
2018-11-26 18:05:06 +01:00
|
|
|
unique_ptr<NotificationType> type;
|
|
|
|
|
2022-04-15 17:36:24 +02:00
|
|
|
Notification(NotificationId notification_id, int32 date, int64 ringtone_id, unique_ptr<NotificationType> type)
|
|
|
|
: notification_id(notification_id), date(date), ringtone_id(ringtone_id), type(std::move(type)) {
|
2018-11-26 18:05:06 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
inline td_api::object_ptr<td_api::notification> get_notification_object(DialogId dialog_id,
|
|
|
|
const Notification ¬ification) {
|
2019-03-31 17:27:35 +02:00
|
|
|
CHECK(notification.type != nullptr);
|
2018-12-20 21:14:19 +01:00
|
|
|
return td_api::make_object<td_api::notification>(notification.notification_id.get(), notification.date,
|
2022-04-15 17:36:24 +02:00
|
|
|
notification.ringtone_id,
|
2018-11-26 18:05:06 +01:00
|
|
|
notification.type->get_notification_type_object(dialog_id));
|
|
|
|
}
|
|
|
|
|
2018-11-29 22:02:33 +01:00
|
|
|
inline StringBuilder &operator<<(StringBuilder &sb, const Notification ¬ification) {
|
2018-11-26 18:05:06 +01:00
|
|
|
return sb << "notification[" << notification.notification_id << ", " << notification.date << ", "
|
2022-04-15 17:36:24 +02:00
|
|
|
<< notification.ringtone_id << ", " << *notification.type << ']';
|
2018-11-26 18:05:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace td
|