2022-08-30 15:02:25 +02:00
|
|
|
//
|
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
|
2022-08-30 15:48:26 +02:00
|
|
|
#include "td/telegram/td_api.h"
|
2022-08-30 15:02:25 +02:00
|
|
|
#include "td/telegram/telegram_api.h"
|
|
|
|
|
|
|
|
#include "td/utils/common.h"
|
2022-08-30 17:03:57 +02:00
|
|
|
#include "td/utils/Promise.h"
|
2022-08-30 15:02:25 +02:00
|
|
|
#include "td/utils/StringBuilder.h"
|
|
|
|
#include "td/utils/tl_helpers.h"
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
2022-08-30 17:03:57 +02:00
|
|
|
class Td;
|
|
|
|
|
2022-08-30 15:02:25 +02:00
|
|
|
class EmojiStatus {
|
|
|
|
int64 custom_emoji_id_ = 0;
|
2022-09-01 21:04:33 +02:00
|
|
|
int32 until_date_ = 0;
|
2022-08-30 15:02:25 +02:00
|
|
|
|
|
|
|
friend bool operator==(const EmojiStatus &lhs, const EmojiStatus &rhs);
|
|
|
|
|
|
|
|
friend StringBuilder &operator<<(StringBuilder &string_builder, const EmojiStatus &contact);
|
|
|
|
|
|
|
|
public:
|
|
|
|
EmojiStatus() = default;
|
|
|
|
|
2022-09-07 09:25:21 +02:00
|
|
|
EmojiStatus(const td_api::object_ptr<td_api::emojiStatus> &emoji_status, int32 duration);
|
2022-08-30 15:02:25 +02:00
|
|
|
|
2022-08-30 16:23:46 +02:00
|
|
|
explicit EmojiStatus(tl_object_ptr<telegram_api::EmojiStatus> &&emoji_status);
|
2022-08-30 15:02:25 +02:00
|
|
|
|
2022-08-30 16:23:46 +02:00
|
|
|
tl_object_ptr<telegram_api::EmojiStatus> get_input_emoji_status() const;
|
2022-08-30 15:02:25 +02:00
|
|
|
|
2022-09-07 09:25:21 +02:00
|
|
|
td_api::object_ptr<td_api::emojiStatus> get_emoji_status_object() const;
|
2022-08-30 15:02:25 +02:00
|
|
|
|
2022-09-01 21:04:33 +02:00
|
|
|
int64 get_effective_custom_emoji_id(bool is_premium, int32 unix_time) const;
|
2022-09-01 19:33:41 +02:00
|
|
|
|
2022-08-30 15:02:25 +02:00
|
|
|
bool is_empty() const {
|
|
|
|
return custom_emoji_id_ == 0;
|
|
|
|
}
|
|
|
|
|
2022-09-02 14:39:07 +02:00
|
|
|
int64 get_custom_emoji_id() const {
|
|
|
|
return custom_emoji_id_;
|
|
|
|
}
|
|
|
|
|
2022-09-01 21:26:04 +02:00
|
|
|
int32 get_until_date() const {
|
|
|
|
return until_date_;
|
|
|
|
}
|
|
|
|
|
2022-09-02 12:16:55 +02:00
|
|
|
void clear_until_date() {
|
|
|
|
until_date_ = 0;
|
|
|
|
}
|
|
|
|
|
2022-08-30 15:02:25 +02:00
|
|
|
template <class StorerT>
|
|
|
|
void store(StorerT &storer) const {
|
2022-09-02 14:39:07 +02:00
|
|
|
bool has_custom_emoji_id = custom_emoji_id_ != 0;
|
2022-09-01 21:04:33 +02:00
|
|
|
bool has_until_date = until_date_ != 0;
|
|
|
|
BEGIN_STORE_FLAGS();
|
2022-09-02 14:39:07 +02:00
|
|
|
STORE_FLAG(has_custom_emoji_id);
|
2022-09-01 21:04:33 +02:00
|
|
|
STORE_FLAG(has_until_date);
|
|
|
|
END_STORE_FLAGS();
|
2022-09-02 14:39:07 +02:00
|
|
|
if (has_custom_emoji_id) {
|
|
|
|
td::store(custom_emoji_id_, storer);
|
|
|
|
}
|
2022-09-01 21:04:33 +02:00
|
|
|
if (has_until_date) {
|
|
|
|
td::store(until_date_, storer);
|
|
|
|
}
|
2022-08-30 15:02:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class ParserT>
|
|
|
|
void parse(ParserT &parser) {
|
2022-09-02 14:39:07 +02:00
|
|
|
bool has_custom_emoji_id;
|
2022-09-01 21:04:33 +02:00
|
|
|
bool has_until_date;
|
|
|
|
BEGIN_PARSE_FLAGS();
|
2022-09-02 14:39:07 +02:00
|
|
|
PARSE_FLAG(has_custom_emoji_id);
|
2022-09-01 21:04:33 +02:00
|
|
|
PARSE_FLAG(has_until_date);
|
|
|
|
END_PARSE_FLAGS();
|
2022-09-02 14:39:07 +02:00
|
|
|
if (has_custom_emoji_id) {
|
|
|
|
td::parse(custom_emoji_id_, parser);
|
|
|
|
}
|
2022-09-01 21:04:33 +02:00
|
|
|
if (has_until_date) {
|
|
|
|
td::parse(until_date_, parser);
|
|
|
|
}
|
2022-08-30 15:02:25 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
inline bool operator==(const EmojiStatus &lhs, const EmojiStatus &rhs) {
|
2022-09-01 21:04:33 +02:00
|
|
|
return lhs.custom_emoji_id_ == rhs.custom_emoji_id_ && lhs.until_date_ == rhs.until_date_;
|
2022-08-30 15:02:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
inline bool operator!=(const EmojiStatus &lhs, const EmojiStatus &rhs) {
|
|
|
|
return !(lhs == rhs);
|
|
|
|
}
|
|
|
|
|
2022-08-30 16:23:46 +02:00
|
|
|
StringBuilder &operator<<(StringBuilder &string_builder, const EmojiStatus &emoji_status);
|
2022-08-30 15:02:25 +02:00
|
|
|
|
2022-09-07 09:25:21 +02:00
|
|
|
void get_default_emoji_statuses(Td *td, Promise<td_api::object_ptr<td_api::emojiStatuses>> &&promise);
|
2022-08-30 17:03:57 +02:00
|
|
|
|
2022-09-07 09:25:21 +02:00
|
|
|
void get_recent_emoji_statuses(Td *td, Promise<td_api::object_ptr<td_api::emojiStatuses>> &&promise);
|
2022-08-31 14:47:51 +02:00
|
|
|
|
2022-09-02 14:39:07 +02:00
|
|
|
void add_recent_emoji_status(Td *td, EmojiStatus emoji_status);
|
2022-08-31 16:46:03 +02:00
|
|
|
|
2022-08-31 15:41:13 +02:00
|
|
|
void clear_recent_emoji_statuses(Td *td, Promise<Unit> &&promise);
|
|
|
|
|
2022-08-30 15:02:25 +02:00
|
|
|
} // namespace td
|