mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-10-25 14:58:42 +00:00
Implement PoC custom reaction selection.
This commit is contained in:
32
Telegram/SourceFiles/data/data_message_reaction_id.cpp
Normal file
32
Telegram/SourceFiles/data/data_message_reaction_id.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
#include "data/data_message_reaction_id.h"
|
||||
|
||||
namespace Data {
|
||||
|
||||
ReactionId ReactionFromMTP(const MTPReaction &reaction) {
|
||||
return reaction.match([](MTPDreactionEmpty) {
|
||||
return ReactionId{ QString() };
|
||||
}, [](const MTPDreactionEmoji &data) {
|
||||
return ReactionId{ qs(data.vemoticon()) };
|
||||
}, [](const MTPDreactionCustomEmoji &data) {
|
||||
return ReactionId{ DocumentId(data.vdocument_id().v) };
|
||||
});
|
||||
}
|
||||
|
||||
MTPReaction ReactionToMTP(ReactionId id) {
|
||||
if (const auto custom = id.custom()) {
|
||||
return MTP_reactionCustomEmoji(MTP_long(custom));
|
||||
}
|
||||
const auto emoji = id.emoji();
|
||||
return emoji.isEmpty()
|
||||
? MTP_reactionEmpty()
|
||||
: MTP_reactionEmoji(MTP_string(emoji));
|
||||
}
|
||||
|
||||
} // namespace Data
|
||||
Reference in New Issue
Block a user