| 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 |
no test coverage detected