2022-08-16 15:52:49 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2023-11-14 10:35:57 +00:00
|
|
|
#include "base/qt/qt_compare.h"
|
|
|
|
|
2022-08-16 15:52:49 +00:00
|
|
|
namespace Data {
|
|
|
|
|
|
|
|
struct ReactionId {
|
|
|
|
std::variant<QString, DocumentId> data;
|
|
|
|
|
|
|
|
[[nodiscard]] bool empty() const {
|
|
|
|
const auto emoji = std::get_if<QString>(&data);
|
|
|
|
return emoji && emoji->isEmpty();
|
|
|
|
}
|
|
|
|
[[nodiscard]] QString emoji() const {
|
|
|
|
const auto emoji = std::get_if<QString>(&data);
|
|
|
|
return emoji ? *emoji : QString();
|
|
|
|
}
|
|
|
|
[[nodiscard]] DocumentId custom() const {
|
|
|
|
const auto custom = std::get_if<DocumentId>(&data);
|
|
|
|
return custom ? *custom : DocumentId();
|
|
|
|
}
|
2023-11-14 10:35:57 +00:00
|
|
|
|
2024-01-09 08:18:55 +00:00
|
|
|
explicit operator bool() const {
|
|
|
|
return !empty();
|
|
|
|
}
|
|
|
|
|
2023-11-14 10:35:57 +00:00
|
|
|
friend inline auto operator<=>(
|
|
|
|
const ReactionId &,
|
|
|
|
const ReactionId &) = default;
|
|
|
|
friend inline bool operator==(
|
|
|
|
const ReactionId &a,
|
|
|
|
const ReactionId &b) = default;
|
2022-08-16 15:52:49 +00:00
|
|
|
};
|
|
|
|
|
2022-08-25 20:56:38 +00:00
|
|
|
struct MessageReaction {
|
|
|
|
ReactionId id;
|
|
|
|
int count = 0;
|
|
|
|
bool my = false;
|
|
|
|
};
|
|
|
|
|
2024-01-09 08:18:55 +00:00
|
|
|
[[nodiscard]] QString SearchTagToQuery(const ReactionId &tagId);
|
|
|
|
[[nodiscard]] ReactionId SearchTagFromQuery(const QString &query);
|
|
|
|
|
2022-08-26 19:53:48 +00:00
|
|
|
[[nodiscard]] QString ReactionEntityData(const ReactionId &id);
|
|
|
|
|
2022-08-16 15:52:49 +00:00
|
|
|
[[nodiscard]] ReactionId ReactionFromMTP(const MTPReaction &reaction);
|
|
|
|
[[nodiscard]] MTPReaction ReactionToMTP(ReactionId id);
|
|
|
|
|
|
|
|
} // namespace Data
|
2022-08-23 20:12:07 +00:00
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(Data::ReactionId);
|