FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
tdesktop/Telegram/SourceFiles/data/data_message_reaction_id.cpp at dev · dmitry/tdesktop · GitHub
dmitry
tdesktop
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
tdesktop
/
Telegram
/
SourceFiles
/
data
/
data_message_reaction_id.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
95 lines (84 loc) · 2.64 KB
Breadcrumbs
tdesktop
/
Telegram
/
SourceFiles
/
data
/
data_message_reaction_id.cpp
Copy path
File metadata and controls
95 lines (84 loc) · 2.64 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
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
"
#
include
"
data/stickers/data_custom_emoji.h
"
namespace
Data
{
QString
SearchTagToQuery
(
const
ReactionId &tagId) {
if
(
const
auto
customId = tagId.
custom
()) {
return
u"
#tag-custom:%1
"
_q.
arg
(customId);
}
else
if
(!tagId) {
return
QString
();
}
return
u"
#tag-emoji:
"
_q + tagId.
emoji
();
}
ReactionId
SearchTagFromQuery
(
const
QString &query) {
const
auto
list = query.
split
(
QChar
(
'
'
));
const
auto
tag = list.
isEmpty
() ?
QString
() : list[
0
];
if
(tag.
startsWith
(
u"
#tag-custom:
"
_q)) {
return
ReactionId{
DocumentId
(tag.
mid
(
12
).
toULongLong
()) };
}
else
if
(tag.
startsWith
(
u"
#tag-emoji:
"
_q)) {
return
ReactionId{ tag.
mid
(
11
) };
}
return
{};
}
std::vector<ReactionId>
SearchTagsFromQuery
(
const
QString &query) {
auto
result = std::vector<ReactionId>();
if
(
const
auto
tag =
SearchTagFromQuery
(query)) {
result.
push_back
(tag);
}
return
result;
}
HashtagWithUsername
HashtagWithUsernameFromQuery
(QStringView query) {
const
auto
match =
TextUtilities::RegExpHashtag
(
true
).
match
(query);
if
(match.
hasMatch
()) {
const
auto
username = match.
capturedView
(
2
).
mid
(
1
).
toString
();
const
auto
offset =
int
(match.
capturedLength
(
1
));
const
auto
full =
int
(query.
size
());
const
auto
length = full
-
int
(username.
size
())
-
1
- offset
-
int
(match.
capturedLength
(
3
));
if
(!username.
isEmpty
() && length >
0
&& offset + length <= full) {
const
auto
hashtag = query.
mid
(offset, length).
toString
();
return
{ hashtag, username };
}
}
return
{};
}
QString
ReactionEntityData
(
const
ReactionId &id) {
if
(id.
empty
()) {
return
{};
}
else
if
(
const
auto
custom = id.
custom
()) {
return
SerializeCustomEmojiId
(custom);
}
return
u"
default:
"
_q + id.
emoji
();
}
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
) };
}, [](
const
MTPDreactionPaid &) {
return
ReactionId::Paid
();
});
}
MTPReaction
ReactionToMTP
(ReactionId id) {
if
(!id) {
return
MTP_reactionEmpty
();
}
else
if
(id.
paid
()) {
return
MTP_reactionPaid
();
}
else
if
(
const
auto
custom = id.
custom
()) {
return
MTP_reactionCustomEmoji
(
MTP_long
(custom));
}
else
{
return
MTP_reactionEmoji
(
MTP_string
(id.
emoji
()));
}
}
}
//
namespace Data
Back
|
FazBrowse Home
|
New Git URL