MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / MentionNameEntity

Function MentionNameEntity

Telegram/SourceFiles/api/api_text_entities.cpp:44–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42}
43
44[[nodiscard]] std::optional<MTPMessageEntity> MentionNameEntity(
45 not_null<Main::Session*> session,
46 MTPint offset,
47 MTPint length,
48 const QString &data) {
49 const auto parsed = MentionNameDataToFields(data);
50 if (!parsed.userId || parsed.selfId != session->userId().bare) {
51 return {};
52 }
53 const auto user = session->data().user(UserId(parsed.userId));
54 const auto item = user->isLoaded()
55 ? nullptr
56 : user->owner().messageWithPeer(user->id);
57 const auto input = item
58 ? MTP_inputUserFromMessage(
59 item->history()->peer->input(),
60 MTP_int(item->id.bare),
61 MTP_long(parsed.userId))
62 : (parsed.userId == parsed.selfId)
63 ? MTP_inputUserSelf()
64 : user->isLoaded()
65 ? user->inputUser()
66 : MTP_inputUser(
67 MTP_long(parsed.userId),
68 MTP_long(parsed.accessHash));
69 return MTP_inputMessageEntityMentionName(offset, length, input);
70}
71
72} // namespace
73

Callers 1

EntitiesToMTPFunction · 0.85

Calls 12

MTP_longFunction · 0.85
isLoadedMethod · 0.80
messageWithPeerMethod · 0.80
inputUserMethod · 0.80
UserIdClass · 0.50
MTP_intFunction · 0.50
userIdMethod · 0.45
userMethod · 0.45
dataMethod · 0.45
ownerMethod · 0.45
inputMethod · 0.45
historyMethod · 0.45

Tested by

no test coverage detected