Initial support for min-user-from-message request.

This commit is contained in:
John Preston
2025-12-18 21:18:33 +04:00
parent 66645ce523
commit 53324d5494
12 changed files with 184 additions and 136 deletions
+19 -8
View File
@@ -12,6 +12,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_user.h"
#include "data/stickers/data_custom_emoji.h"
#include "data/stickers/data_stickers_set.h"
#include "history/history.h"
#include "history/history_item.h"
#include "main/main_session.h"
namespace Api {
@@ -47,14 +49,23 @@ using namespace TextUtilities;
if (!parsed.userId || parsed.selfId != session->userId().bare) {
return {};
}
return MTP_inputMessageEntityMentionName(
offset,
length,
(parsed.userId == parsed.selfId
? MTP_inputUserSelf()
: MTP_inputUser(
MTP_long(parsed.userId),
MTP_long(parsed.accessHash))));
const auto user = session->data().user(UserId(parsed.userId));
const auto item = user->isLoaded()
? nullptr
: user->owner().messageWithPeer(user->id);
const auto input = item
? MTP_inputUserFromMessage(
item->history()->peer->input(),
MTP_int(item->id.bare),
MTP_long(parsed.userId))
: (parsed.userId == parsed.selfId)
? MTP_inputUserSelf()
: user->isLoaded()
? user->inputUser()
: MTP_inputUser(
MTP_long(parsed.userId),
MTP_long(parsed.accessHash));
return MTP_inputMessageEntityMentionName(offset, length, input);
}
} // namespace