Full support and build fix.

This commit is contained in:
John Preston
2025-12-18 22:25:12 +04:00
parent 53324d5494
commit 28434f4bee
136 changed files with 681 additions and 692 deletions

View File

@@ -85,7 +85,7 @@ void Chatbots::save(
api->request(MTPaccount_UpdateConnectedBot(
MTP_flags(!settings.bot ? Flag::f_deleted : Flag::f_rights),
ToMTP(settings.permissions),
(settings.bot ? settings.bot : was.bot)->inputUser,
(settings.bot ? settings.bot : was.bot)->inputUser(),
ForBotsToMTP(settings.recipients)
)).done([=](const MTPUpdates &result) {
api->applyUpdates(result);
@@ -117,7 +117,7 @@ void Chatbots::togglePaused(not_null<PeerData*> peer, bool paused) {
_sentRequests.erase(i);
}
const auto id = api->request(MTPaccount_ToggleConnectedBotPaused(
peer->input,
peer->input(),
MTP_bool(paused)
)).done([=] {
if (_sentRequests[peer].type != type) {
@@ -155,7 +155,7 @@ void Chatbots::removeFrom(not_null<PeerData*> peer) {
_sentRequests.erase(i);
}
const auto id = api->request(MTPaccount_DisablePeerConnectedBot(
peer->input
peer->input()
)).done([=] {
if (_sentRequests[peer].type != type) {
return;

View File

@@ -91,7 +91,7 @@ void Factchecks::request() {
}
}
_requestId = _session->api().request(MTPmessages_GetFactCheck(
history->peer->input,
history->peer->input(),
MTP_vector<MTPint>(std::move(ids))
)).done([=](const MTPVector<MTPFactCheck> &result) {
_requestId = 0;
@@ -170,7 +170,7 @@ void Factchecks::save(
return;
} else if (text.empty()) {
_session->api().request(MTPmessages_DeleteFactCheck(
item->history()->peer->input,
item->history()->peer->input(),
MTP_int(item->id.bare)
)).done([=](const MTPUpdates &result) {
_session->api().applyUpdates(result);
@@ -180,7 +180,7 @@ void Factchecks::save(
}).send();
} else {
_session->api().request(MTPmessages_EditFactCheck(
item->history()->peer->input,
item->history()->peer->input(),
MTP_int(item->id.bare),
MTP_textWithEntities(
MTP_string(text.text),

View File

@@ -79,7 +79,7 @@ void RecentSharedMediaGifts::request(
_recent[peer->id].requestId = peer->session().api().request(
MTPpayments_GetSavedStarGifts(
MTP_flags(0),
peer->input,
peer->input(),
MTP_int(0), // collection_id
MTP_string(QString()),
MTP_int(kMaxPinnedGifts)
@@ -128,7 +128,7 @@ void RecentSharedMediaGifts::updatePinnedOrder(
}
_session->api().request(MTPpayments_ToggleStarGiftsPinnedToTop(
peer->input,
peer->input(),
MTP_vector<MTPInputSavedStarGift>(std::move(inputs))
)).done([=] {
auto result = std::deque<SavedStarGift>();

View File

@@ -485,7 +485,7 @@ void ScheduledMessages::request(not_null<History*> history) {
? countListHash(i->second)
: uint64(0);
request.requestId = _session->api().request(
MTPmessages_GetScheduledHistory(peer->input, MTP_long(hash))
MTPmessages_GetScheduledHistory(peer->input(), MTP_long(hash))
).done([=](const MTPmessages_Messages &result) {
parse(history, result);
}).fail([=] {

View File

@@ -285,7 +285,7 @@ void SponsoredMessages::request(not_null<History*> history, Fn<void()> done) {
request.requestId = _session->api().request(
MTPmessages_GetSponsoredMessages(
MTP_flags(0),
history->peer->input,
history->peer->input(),
MTPint()) // msg_id
).done([=](const MTPmessages_sponsoredMessages &result) {
parse(history, result);
@@ -346,7 +346,7 @@ void SponsoredMessages::requestForVideo(
request.requestId = _session->api().request(
MTPmessages_GetSponsoredMessages(
MTP_flags(Flag::f_msg_id),
peer->input,
peer->input(),
MTP_int(item->id.bare))
).done([=](const MTPmessages_sponsoredMessages &result) {
parseForVideo(peer, result);

View File

@@ -109,7 +109,7 @@ void TopPeers::remove(not_null<PeerData*> peer) {
_requestId = _session->api().request(MTPcontacts_ResetTopPeerRating(
TypeToCategory(_type),
peer->input
peer->input()
)).send();
}

View File

@@ -116,8 +116,6 @@ std::unique_ptr<Data::SavedMessages> MegagroupInfo::takeMonoforumData() {
ChannelData::ChannelData(not_null<Data::Session*> owner, PeerId id)
: PeerData(owner, id)
, inputChannel(
MTP_inputChannel(MTP_long(peerToChannel(id).bare), MTP_long(0)))
, _ptsWaiter(&owner->session().updates()) {
}
@@ -176,13 +174,7 @@ bool ChannelData::isUsernameEditable(QString username) const {
}
void ChannelData::setAccessHash(uint64 accessHash) {
access = accessHash;
input = MTP_inputPeerChannel(
MTP_long(peerToChannel(id).bare),
MTP_long(accessHash));
inputChannel = MTP_inputChannel(
MTP_long(peerToChannel(id).bare),
MTP_long(accessHash));
_accessHash = accessHash;
}
void ChannelData::setFlags(ChannelDataFlags which) {
@@ -604,7 +596,7 @@ void ChannelData::markForbidden() {
? MTPDchannelForbidden::Flag::f_megagroup
: MTPDchannelForbidden::Flag::f_broadcast),
MTP_long(peerToChannel(id).bare),
MTP_long(access),
MTP_long(_accessHash),
MTP_string(name()),
MTPint()));
}

View File

@@ -194,6 +194,10 @@ public:
void setUsername(const QString &username);
void setUsernames(const Data::Usernames &newUsernames);
void setPhoto(const MTPChatPhoto &photo);
[[nodiscard]] uint64 accessHash() const {
return _accessHash;
}
void setAccessHash(uint64 accessHash);
void setFlags(ChannelDataFlags which);

View File

@@ -27,8 +27,7 @@ using UpdateFlag = Data::PeerUpdate::Flag;
} // namespace
ChatData::ChatData(not_null<Data::Session*> owner, PeerId id)
: PeerData(owner, id)
, inputChat(MTP_long(peerToChat(id).bare)) {
: PeerData(owner, id) {
_flags.changes(
) | rpl::on_next([=](const Flags::Change &change) {
if (change.diff & Flag::CallNotEmpty) {

View File

@@ -230,13 +230,13 @@ MTPDialogFilter ChatFilter::tl(FilterId replaceId) const {
auto pinned = QVector<MTPInputPeer>();
pinned.reserve(_pinned.size());
for (const auto &history : _pinned) {
pinned.push_back(history->peer->input);
pinned.push_back(history->peer->input());
always.remove(history);
}
auto include = QVector<MTPInputPeer>();
include.reserve(always.size());
for (const auto &history : always) {
include.push_back(history->peer->input);
include.push_back(history->peer->input());
}
auto title = MTP_textWithEntities(
MTP_string(_title.text),
@@ -275,7 +275,7 @@ MTPDialogFilter ChatFilter::tl(FilterId replaceId) const {
auto never = QVector<MTPInputPeer>();
never.reserve(_never.size());
for (const auto &history : _never) {
never.push_back(history->peer->input);
never.push_back(history->peer->input());
}
return MTP_dialogFilter(
MTP_flags(flags),
@@ -944,7 +944,7 @@ bool ChatFilters::loadNextExceptions(bool chatsListLoaded) {
for (const auto &history : i->always()) {
if (!history->folderKnown()) {
inputs.push_back(
MTP_inputDialogPeer(history->peer->input));
MTP_inputDialogPeer(history->peer->input()));
}
}
}

View File

@@ -61,7 +61,7 @@ constexpr auto ByDocument = [](const auto &entry) {
if (const auto user = peer->asUser()) {
return user->accessHash();
} else if (const auto channel = peer->asChannel()) {
return channel->access;
return channel->accessHash();
}
return 0;
}

View File

@@ -534,7 +534,7 @@ void EmojiStatuses::set(
if (peer->isSelf()) {
send(MTPaccount_UpdateEmojiStatus(status));
} else if (const auto channel = peer->asChannel()) {
send(MTPchannels_UpdateEmojiStatus(channel->inputChannel, status));
send(MTPchannels_UpdateEmojiStatus(channel->inputChannel(), status));
}
}

View File

@@ -162,7 +162,7 @@ void Forum::requestTopics() {
const auto loadCount = firstLoad ? kTopicsFirstLoad : kTopicsPerPage;
_requestId = session().api().request(MTPmessages_GetForumTopics(
MTP_flags(0),
peer()->input,
peer()->input(),
MTPstring(), // q
MTP_int(_offset.date),
MTP_int(_offset.id),
@@ -425,7 +425,7 @@ void Forum::requestSomeStale() {
Fn<void()> finish) {
return session().api().request(
MTPmessages_GetForumTopicsByID(
peer()->input,
peer()->input(),
MTP_vector<MTPint>(rootIds))
).done([=](const MTPmessages_ForumTopics &result) {
_staleRequestId = 0;

View File

@@ -477,7 +477,7 @@ void ForumTopic::setClosedAndSave(bool closed) {
const auto weak = base::make_weak(this);
api->request(MTPmessages_EditForumTopic(
MTP_flags(MTPmessages_EditForumTopic::Flag::f_closed),
peer()->input,
peer()->input(),
MTP_int(_rootId),
MTPstring(), // title
MTPlong(), // icon_emoji_id

View File

@@ -1152,7 +1152,7 @@ void GroupCall::saveSendAs(not_null<PeerData*> peer) {
_savedSendAs = peer;
api().request(MTPphone_SaveDefaultSendAs(
input(),
peer->input
peer->input()
)).send();
}

View File

@@ -46,7 +46,7 @@ MTPInputReplyTo ReplyToForMTP(
if (replyTo.storyId) {
if (const auto peer = owner->peerLoaded(replyTo.storyId.peer)) {
return MTP_inputReplyToStory(
peer->input,
peer->input(),
MTP_int(replyTo.storyId.story));
}
} else if (replyTo.messageId || replyTo.topicRootId) {
@@ -95,13 +95,13 @@ MTPInputReplyTo ReplyToForMTP(
MTP_int(replyTo.messageId ? replyTo.messageId.msg : 0),
MTP_int(replyTo.topicRootId),
(external
? owner->peer(replyTo.messageId.peer)->input
? owner->peer(replyTo.messageId.peer)->input()
: MTPInputPeer()),
MTP_string(replyTo.quote.text),
quoteEntities,
MTP_int(replyTo.quoteOffset),
(replyToMonoforumPeerId
? history->owner().peer(replyToMonoforumPeerId)->input
? history->owner().peer(replyToMonoforumPeerId)->input()
: MTPInputPeer()),
MTP_int(replyTo.todoItemId));
} else if (history->peer->amMonoforumAdmin()
@@ -109,7 +109,7 @@ MTPInputReplyTo ReplyToForMTP(
const auto replyToMonoforumPeer = replyTo.monoforumPeerId
? history->owner().peer(replyTo.monoforumPeerId)
: history->session().user();
return MTP_inputReplyToMonoForum(replyToMonoforumPeer->input);
return MTP_inputReplyToMonoForum(replyToMonoforumPeer->input());
}
return MTPInputReplyTo();
}
@@ -421,7 +421,7 @@ void Histories::sendDialogRequests() {
auto peers = QVector<MTPInputDialogPeer>();
const auto dialogPeer = [](not_null<History*> history) {
return MTP_inputDialogPeer(history->peer->input);
return MTP_inputDialogPeer(history->peer->input());
};
ranges::transform(
histories,
@@ -501,7 +501,7 @@ void Histories::changeDialogUnreadMark(
session().api().request(MTPmessages_MarkDialogUnread(
MTP_flags(unread ? Flag::f_unread : Flag(0)),
MTPInputPeer(), // parent_peer
MTP_inputDialogPeer(history->peer->input)
MTP_inputDialogPeer(history->peer->input())
)).send();
}
@@ -518,8 +518,8 @@ void Histories::changeSublistUnreadMark(
session().api().request(MTPmessages_MarkDialogUnread(
MTP_flags(Flag::f_parent_peer
| (unread ? Flag::f_unread : Flag(0))),
parent->input,
MTP_inputDialogPeer(sublist->sublistPeer()->input)
parent->input(),
MTP_inputDialogPeer(sublist->sublistPeer()->input())
)).send();
}
@@ -532,7 +532,7 @@ void Histories::requestFakeChatListMessage(
_fakeChatListRequests.emplace(history);
sendRequest(history, RequestType::History, [=](Fn<void()> finish) {
return session().api().request(MTPmessages_GetHistory(
history->peer->input,
history->peer->input(),
MTP_int(0), // offset_id
MTP_int(0), // offset_date
MTP_int(0), // add_offset
@@ -573,7 +573,7 @@ void Histories::requestGroupAround(not_null<HistoryItem*> item) {
const auto requestId = sendRequest(history, RequestType::History, [=](
Fn<void()> finish) {
return session().api().request(MTPmessages_GetHistory(
history->peer->input,
history->peer->input(),
MTP_int(id),
MTP_int(0), // offset_date
MTP_int(-kMaxAlbumCount),
@@ -658,7 +658,7 @@ void Histories::reportPendingDeliveries() {
};
session().api().request(MTPmessages_ReportMessagesDelivery(
MTP_flags(0),
peer->input,
peer->input(),
MTP_vector(std::move(list))
)).done(finish).fail(finish).send();
}
@@ -722,12 +722,12 @@ void Histories::sendReadRequest(not_null<History*> history, State &state) {
};
if (const auto channel = history->peer->asChannel()) {
return session().api().request(MTPchannels_ReadHistory(
channel->inputChannel,
channel->inputChannel(),
MTP_int(tillId)
)).done(finished).fail(finished).send();
} else {
return session().api().request(MTPmessages_ReadHistory(
history->peer->input,
history->peer->input(),
MTP_int(tillId)
)).done([=](const MTPmessages_AffectedMessages &result) {
session().api().applyAffectedMessages(history->peer, result);
@@ -779,7 +779,7 @@ void Histories::deleteMessages(
};
if (const auto channel = history->peer->asChannel()) {
return session().api().request(MTPchannels_DeleteMessages(
channel->inputChannel,
channel->inputChannel(),
MTP_vector<MTPint>(ids)
)).done(done).fail(finish).send();
} else {
@@ -803,7 +803,7 @@ void Histories::deleteAllMessages(
const auto channel = peer->asChannel();
if (!justClear && revoke && channel && channel->canDelete()) {
return session().api().request(MTPchannels_DeleteChannel(
channel->inputChannel
channel->inputChannel()
)).done([=](const MTPUpdates &result) {
session().api().applyUpdates(result);
//}).fail([=](const MTP::Error &error) {
@@ -815,18 +815,18 @@ void Histories::deleteAllMessages(
using Flag = MTPchannels_DeleteHistory::Flag;
return session().api().request(MTPchannels_DeleteHistory(
MTP_flags(revoke ? Flag::f_for_everyone : Flag(0)),
channel->inputChannel,
channel->inputChannel(),
MTP_int(deleteTillId)
)).done(finish).fail(finish).send();
} else if (!justClear && revoke && chat && chat->amCreator()) {
return session().api().request(MTPmessages_DeleteChat(
chat->inputChat
chat->inputChat()
)).done(finish).fail([=](const MTP::Error &error) {
if (error.type() == "PEER_ID_INVALID") {
// Try to join and delete,
// while delete fails for non-joined.
session().api().request(MTPmessages_AddChatUser(
chat->inputChat,
chat->inputChat(),
MTP_inputUserSelf(),
MTP_int(0)
)).done([=](const MTPmessages_InvitedUsers &result) {
@@ -848,7 +848,7 @@ void Histories::deleteAllMessages(
| (revoke ? Flag::f_revoke : Flag(0));
return session().api().request(MTPmessages_DeleteHistory(
MTP_flags(flags),
peer->input,
peer->input(),
MTP_int(0),
MTPint(), // min_date
MTPint() // max_date
@@ -901,7 +901,7 @@ void Histories::deleteMessagesByDates(
| (revoke ? Flag::f_revoke : Flag(0));
return session().api().request(MTPmessages_DeleteHistory(
MTP_flags(flags),
peer->input,
peer->input(),
MTP_int(0),
MTP_int(minDate),
MTP_int(maxDate)
@@ -965,7 +965,7 @@ void Histories::deleteMessages(const MessageIdsList &ids, bool revoke) {
}
for (const auto &[peer, ids] : scheduledIdsByPeer) {
peer->session().api().request(MTPmessages_DeleteScheduledMessages(
peer->input,
peer->input(),
MTP_vector<MTPint>(ids)
)).done([peer = peer](const MTPUpdates &result) {
peer->session().api().applyUpdates(result);
@@ -1058,7 +1058,7 @@ void Histories::sendCreateTopicRequest(
MTP_flags(Flag::f_icon_color
| (topic->iconId() ? Flag::f_icon_emoji_id : Flag())
| (history->peer->isBot() ? Flag::f_title_missing : Flag())),
history->peer->input,
history->peer->input(),
MTP_string(topic->title()),
MTP_int(topic->colorId()),
MTP_long(topic->iconId()),

View File

@@ -172,7 +172,7 @@ constexpr auto kPaidAccumulatePeriod = 5 * crl::time(1000) + 500;
: (*shownPeer == session->userPeerId())
? MTP_paidReactionPrivacyDefault()
: MTP_paidReactionPrivacyPeer(
session->data().peer(*shownPeer)->input);
session->data().peer(*shownPeer)->input());
}
} // namespace
@@ -1058,7 +1058,7 @@ void Reactions::requestMyTags(SavedSublist *sublist) {
using Flag = MTPmessages_GetSavedReactionTags::Flag;
my.requestId = api.request(MTPmessages_GetSavedReactionTags(
MTP_flags(sublist ? Flag::f_peer : Flag()),
(sublist ? sublist->sublistPeer()->input : MTP_inputPeerEmpty()),
(sublist ? sublist->sublistPeer()->input() : MTP_inputPeerEmpty()),
MTP_long(my.hash)
)).done([=](const MTPmessages_SavedReactionTags &result) {
auto &my = _myTags[sublist];
@@ -1504,7 +1504,7 @@ void Reactions::send(not_null<HistoryItem*> item, bool addToRecent) {
| (addToRecent ? Flag::f_add_to_recent : Flag(0));
i->second = api.request(MTPmessages_SendReaction(
MTP_flags(flags),
item->history()->peer->input,
item->history()->peer->input(),
MTP_int(id.msg),
MTP_vector<MTPReaction>(chosen | ranges::views::filter([](
const ReactionId &id) {
@@ -1728,7 +1728,7 @@ void Reactions::pollCollected() {
}
};
_pollRequestId = api.request(MTPmessages_GetMessagesReactions(
peer->input,
peer->input(),
MTP_vector<MTPint>(ids)
)).done([=](const MTPUpdates &result) {
_owner->session().api().applyUpdates(result);
@@ -1832,7 +1832,7 @@ void Reactions::sendPaidPrivacyRequest(
auto &api = _owner->session().api();
const auto requestId = api.request(
MTPmessages_TogglePaidReactionPrivacy(
item->history()->peer->input,
item->history()->peer->input(),
MTP_int(id.msg),
PaidReactionShownPeerToTL(&_owner->session(), send.shownPeer))
).done([=] {
@@ -1869,7 +1869,7 @@ void Reactions::sendPaidRequest(
using Flag = MTPmessages_SendPaidReaction::Flag;
const auto requestId = api.request(MTPmessages_SendPaidReaction(
MTP_flags(send.shownPeer ? Flag::f_private : Flag()),
item->history()->peer->input,
item->history()->peer->input(),
MTP_int(id.msg),
MTP_int(send.count),
MTP_long(randomId),

View File

@@ -599,7 +599,7 @@ void PeerData::updateUserpic(
isSelf() ? peerToUser(id) : UserId(),
MTP_inputPeerPhotoFileLocation(
MTP_flags(0),
input,
input(),
MTP_long(photoId))) },
kUserpicSize,
kUserpicSize),
@@ -874,7 +874,7 @@ void PeerData::saveTranslationDisabled(bool disabled) {
using Flag = MTPmessages_TogglePeerTranslations::Flag;
session().api().request(MTPmessages_TogglePeerTranslations(
MTP_flags(disabled ? Flag::f_disabled : Flag()),
input
input()
)).send();
}

View File

@@ -534,7 +534,7 @@ void RepliesList::loadAround(MsgId id) {
const auto send = [=](Fn<void()> finish) {
return _history->session().api().request(MTPmessages_GetReplies(
_history->peer->input,
_history->peer->input(),
MTP_int(_rootId),
MTP_int(id), // offset_id
MTP_int(0), // offset_date
@@ -591,7 +591,7 @@ void RepliesList::loadBefore() {
const auto last = _list.back();
const auto send = [=](Fn<void()> finish) {
return _history->session().api().request(MTPmessages_GetReplies(
_history->peer->input,
_history->peer->input(),
MTP_int(_rootId),
MTP_int(last), // offset_id
MTP_int(0), // offset_date
@@ -635,7 +635,7 @@ void RepliesList::loadAfter() {
const auto first = _list.front();
const auto send = [=](Fn<void()> finish) {
return _history->session().api().request(MTPmessages_GetReplies(
_history->peer->input,
_history->peer->input(),
MTP_int(_rootId),
MTP_int(first + 1), // offset_id
MTP_int(0), // offset_date
@@ -940,7 +940,7 @@ void RepliesList::requestUnreadCount() {
};
_reloadUnreadCountRequestId = session->api().request(
MTPmessages_GetDiscussionMessage(
_history->peer->input,
_history->peer->input(),
MTP_int(_rootId))
).done([=](const MTPmessages_DiscussionMessage &result) {
if (weak) {
@@ -1004,7 +1004,7 @@ void RepliesList::sendReadTillRequest() {
api->request(base::take(_readRequestId)).cancel();
_readRequestId = api->request(MTPmessages_ReadDiscussion(
_history->peer->input,
_history->peer->input(),
MTP_int(_rootId),
MTP_int(computeInboxReadTillFull())
)).done(crl::guard(this, [=] {

View File

@@ -164,7 +164,7 @@ void SavedMessages::requestSomeStale() {
i = _stalePeers.erase(i);
peers.push_back(peer);
peerIds.push_back(peer->input);
peerIds.push_back(peer->input());
if (peerIds.size() == kStalePerRequest) {
break;
}
@@ -192,7 +192,7 @@ void SavedMessages::requestSomeStale() {
return session().api().request(
MTPmessages_GetSavedDialogsByID(
MTP_flags(Flag::f_parent_peer),
_parentChat->input,
_parentChat->input(),
MTP_vector<MTPInputPeer>(peerIds))
).done([=](const MTPmessages_SavedDialogs &result) {
_staleRequestId = 0;
@@ -276,10 +276,10 @@ void SavedMessages::sendLoadMore() {
MTPmessages_GetSavedDialogs(
MTP_flags(Flag::f_exclude_pinned
| (_parentChat ? Flag::f_parent_peer : Flag(0))),
_parentChat ? _parentChat->input : MTPInputPeer(),
_parentChat ? _parentChat->input() : MTPInputPeer(),
MTP_int(_offset.date),
MTP_int(_offset.id),
_offset.peer ? _offset.peer->input : MTP_inputPeerEmpty(),
_offset.peer ? _offset.peer->input() : MTP_inputPeerEmpty(),
MTP_int(_offset.id ? kListPerPage : kListFirstPerPage),
MTP_long(0)) // hash
).done([=](const MTPmessages_SavedDialogs &result) {

View File

@@ -269,7 +269,7 @@ void SavedMusic::loadMore(PeerId peerId, bool reload) {
entry.reloading = reload;
entry.requestId = _owner->session().api().request(MTPusers_GetSavedMusic(
user->inputUser,
user->inputUser(),
MTP_int(reload ? 0 : entry.list.size()),
MTP_int(kPerPage),
MTP_long(reload ? firstPageHash(entry) : 0)

View File

@@ -677,8 +677,8 @@ void SavedSublist::sendReadTillRequest() {
_sentReadTill = computeInboxReadTillFull();
_readRequestId = api->request(MTPmessages_ReadSavedHistory(
parentChat->input,
sublistPeer()->input,
parentChat->input(),
sublistPeer()->input(),
MTP_int(_sentReadTill.bare)
)).done(crl::guard(this, [=] {
_readRequestId = 0;
@@ -1112,8 +1112,8 @@ void SavedSublist::loadAround(MsgId id) {
const auto parentChat = _parent->parentChat();
return session().api().request(MTPmessages_GetSavedHistory(
MTP_flags(parentChat ? Flag::f_parent_peer : Flag(0)),
parentChat ? parentChat->input : MTPInputPeer(),
sublistPeer()->input,
parentChat ? parentChat->input() : MTPInputPeer(),
sublistPeer()->input(),
MTP_int(id), // offset_id
MTP_int(0), // offset_date
MTP_int(id ? (-kMessagesPerPage / 2) : 0), // add_offset
@@ -1184,8 +1184,8 @@ void SavedSublist::loadBefore() {
const auto parentChat = _parent->parentChat();
return session().api().request(MTPmessages_GetSavedHistory(
MTP_flags(parentChat ? Flag::f_parent_peer : Flag(0)),
parentChat ? parentChat->input : MTPInputPeer(),
sublistPeer()->input,
parentChat ? parentChat->input() : MTPInputPeer(),
sublistPeer()->input(),
MTP_int(last), // offset_id
MTP_int(0), // offset_date
MTP_int(0), // add_offset
@@ -1231,8 +1231,8 @@ void SavedSublist::loadAfter() {
const auto parentChat = _parent->parentChat();
return session().api().request(MTPmessages_GetSavedHistory(
MTP_flags(parentChat ? Flag::f_parent_peer : Flag(0)),
parentChat ? parentChat->input : MTPInputPeer(),
sublistPeer()->input,
parentChat ? parentChat->input() : MTPInputPeer(),
sublistPeer()->input(),
MTP_int(first + 1), // offset_id
MTP_int(0), // offset_date
MTP_int(-kMessagesPerPage), // add_offset

View File

@@ -83,7 +83,7 @@ std::optional<GlobalMediaRequest> PrepareGlobalMediaRequest(
MTP_int(maxDate),
MTP_int(offsetRate),
(offsetPosition.fullId.peer
? session->data().peer(PeerId(offsetPosition.fullId.peer))->input
? session->data().peer(PeerId(offsetPosition.fullId.peer))->input()
: MTP_inputPeerEmpty()),
MTP_int(offsetPosition.fullId.msg),
MTP_int(limit));
@@ -171,11 +171,11 @@ std::optional<SearchRequest> PrepareSearchRequest(
return MTPmessages_Search(
MTP_flags((topicRootId ? Flag::f_top_msg_id : Flag(0))
| (monoforumPeerId ? Flag::f_saved_peer_id : Flag(0))),
peer->input,
peer->input(),
MTP_string(query),
MTP_inputPeerEmpty(),
(monoforumPeerId
? peer->owner().peer(monoforumPeerId)->input
? peer->owner().peer(monoforumPeerId)->input()
: MTPInputPeer()),
MTPVector<MTPReaction>(), // saved_reaction
MTP_int(topicRootId),
@@ -311,7 +311,7 @@ HistoryRequest PrepareHistoryRequest(
int64(0),
int64(0x3FFFFFFF)));
return MTPmessages_GetHistory(
peer->input,
peer->input(),
MTP_int(mtpOffsetId),
MTP_int(offsetDate),
MTP_int(addOffset),

View File

@@ -479,8 +479,6 @@ not_null<PeerData*> Session::peer(PeerId id) {
}
Unexpected("Peer id type.");
}();
result->input = MTPinputPeer(MTP_inputPeerEmpty());
return _peers.emplace(id, std::move(result)).first->second.get();
}
@@ -540,8 +538,6 @@ not_null<UserData*> Session::processUser(const MTPUser &data) {
data.match([&](const MTPDuserEmpty &data) {
const auto canShareThisContact = result->canShareThisContactFast();
result->input = MTP_inputPeerUser(data.vid(), MTP_long(0));
result->inputUser = MTP_inputUser(data.vid(), MTP_long(0));
result->setName(tr::lng_deleted(tr::now), QString(), QString(), QString());
result->setPhoto(MTP_userProfilePhotoEmpty());
result->setFlags(UserDataFlag::Deleted);
@@ -634,18 +630,7 @@ not_null<UserData*> Session::processUser(const MTPUser &data) {
result->setFlags((result->flags() & ~flagsMask) | flagsSet);
result->setBotVerifyDetailsIcon(
data.vbot_verification_icon().value_or_empty());
if (minimal) {
if (result->input.type() == mtpc_inputPeerEmpty) {
result->input = MTP_inputPeerUser(
data.vid(),
MTP_long(data.vaccess_hash().value_or_empty()));
}
if (result->inputUser.type() == mtpc_inputUserEmpty) {
result->inputUser = MTP_inputUser(
data.vid(),
MTP_long(data.vaccess_hash().value_or_empty()));
}
} else {
if (!minimal) {
if (storiesState) {
result->setStoriesState(storiesState->hasVideoStream
? PeerData::StoriesState::HasVideoStream
@@ -655,16 +640,6 @@ not_null<UserData*> Session::processUser(const MTPUser &data) {
? PeerData::StoriesState::HasUnread
: PeerData::StoriesState::HasRead);
}
if (data.is_self()) {
result->input = MTP_inputPeerSelf();
result->inputUser = MTP_inputUserSelf();
} else if (const auto accessHash = data.vaccess_hash()) {
result->input = MTP_inputPeerUser(data.vid(), *accessHash);
result->inputUser = MTP_inputUser(data.vid(), *accessHash);
} else {
result->input = MTP_inputPeerUser(data.vid(), MTP_long(result->accessHash()));
result->inputUser = MTP_inputUser(data.vid(), MTP_long(result->accessHash()));
}
result->setUnavailableReasons(Data::UnavailableReason::Extract(
data.vrestriction_reason()));
}
@@ -849,7 +824,6 @@ not_null<PeerData*> Session::processChat(const MTPChat &data) {
chat->invalidateParticipants();
}
chat->input = MTP_inputPeerChat(data.vid());
chat->setName(qs(data.vtitle()));
chat->setPhoto(data.vphoto());
chat->date = data.vdate().v;
@@ -869,7 +843,7 @@ not_null<PeerData*> Session::processChat(const MTPChat &data) {
migratedTo->match([&](const MTPDinputChannel &input) {
const auto channel = this->channel(input.vchannel_id().v);
channel->addFlags(ChannelDataFlag::Megagroup);
if (!channel->access) {
if (!channel->accessHash()) {
channel->setAccessHash(input.vaccess_hash().v);
}
ApplyMigration(chat, channel);
@@ -909,7 +883,6 @@ not_null<PeerData*> Session::processChat(const MTPChat &data) {
const auto canAddMembers = chat->canAddMembers();
chat->input = MTP_inputPeerChat(data.vid());
chat->setName(qs(data.vtitle()));
chat->setPhoto(MTP_chatPhotoEmpty());
chat->date = 0;
@@ -955,8 +928,8 @@ not_null<PeerData*> Session::processChat(const MTPChat &data) {
channel->setEmojiStatus(EmojiStatusId());
}
if (minimal) {
if (channel->input.type() == mtpc_inputPeerEmpty
|| channel->inputChannel.type() == mtpc_inputChannelEmpty) {
if (channel->input().type() == mtpc_inputPeerEmpty
|| channel->inputChannel().type() == mtpc_inputChannelEmpty) {
channel->setAccessHash(data.vaccess_hash().value_or_empty());
}
} else {
@@ -971,7 +944,7 @@ not_null<PeerData*> Session::processChat(const MTPChat &data) {
channel->setRestrictions(ChatRestrictionsInfo());
}
channel->setAccessHash(
data.vaccess_hash().value_or(channel->access));
data.vaccess_hash().value_or(channel->accessHash()));
channel->date = data.vdate().v;
channel->setUnavailableReasons(Data::UnavailableReason::Extract(
data.vrestriction_reason()));
@@ -2228,7 +2201,7 @@ void Session::nextForUpgradeGiftRequest(
MTP_flags(Flag::f_exclude_unique
| Flag::f_exclude_unlimited
| Flag::f_exclude_unupgradable),
owner->input,
owner->input(),
MTPint(), // collection_id
MTP_string(), // offset
MTP_int(1)) // limit
@@ -5252,7 +5225,7 @@ void Session::saveViewAsMessages(
}
_viewAsMessagesRequests[channel] = _session->api().request(
MTPchannels_ToggleViewForumAsMessages(
channel->inputChannel,
channel->inputChannel(),
MTP_bool(viewAsMessages))
).done([=] {
_viewAsMessagesRequests.remove(channel);
@@ -5363,70 +5336,126 @@ void Session::clearLocalStorage() {
_bigFileCache->clear();
}
void Session::fillMessagePeers(const MTPMessage &message) {
void Session::fillMessagePeer(FullMsgId fullId, PeerId peerId) {
if (!peerLoaded(peerId)) {
_messagesWithPeer[peerId].push_back(fullId);
}
}
void Session::fillForwardedInfo(
FullMsgId fullId,
const MTPMessageFwdHeader &header) {
return header.match([&](const MTPDmessageFwdHeader &data) {
if (const auto fromId = data.vfrom_id()) {
fillMessagePeer(fullId, peerFromMTP(*fromId));
}
});
}
void Session::fillMentionUsers(
FullMsgId fullId,
const MTPVector<MTPMessageEntity> &entities) {
for (const auto &entity : entities.v) {
entity.match([&](const MTPDmessageEntityMentionName &data) {
fillMessagePeer(fullId, peerFromUser(data.vuser_id()));
}, [&](const MTPDinputMessageEntityMentionName &data) {
data.vuser_id().match([&](const MTPDinputUser &data) {
fillMessagePeer(fullId, peerFromUser(data.vuser_id()));
}, [](const auto &) {});
}, [](const auto &) {});
}
}
void Session::fillMessagePeers(PeerId peerId, const MTPMessage &message) {
const auto id = IdFromMessage(message);
const auto peerId = PeerFromMessage(message);
if (!IsServerMsgId(id)) {
return;
}
const auto fullId = FullMsgId(peerId, id);
fillMessagePeer(fullId, peerId);
return message.match([&](const MTPDmessage &data) {
if (const auto fromId = data.vfrom_id()) {
fillMessagePeer(fullId, peerFromMTP(*fromId));
}
if (const auto viaBotId = data.vvia_bot_id()) {
fillMessagePeer(fullId, peerFromUser(*viaBotId));
}
if (const auto fwd = data.vfwd_from()) {
fillForwardedInfo(fullId, *fwd);
}
if (const auto entities = data.ventities()) {
fillMentionUsers(fullId, *entities);
}
}, [&](const MTPDmessageService &data) {
if (const auto fromId = data.vfrom_id()) {
fillMessagePeer(fullId, peerFromMTP(*fromId));
}
return data.vaction().match(
[&](const MTPDmessageActionChatAddUser &data) {
for (const auto &userId : data.vusers().v) {
fillMessagePeer(fullId, peerFromUser(userId));
}
}, [&](const MTPDmessageActionChatJoinedByLink &data) {
fillMessagePeer(fullId, peerFromUser(data.vinviter_id()));
}, [&](const MTPDmessageActionChatDeleteUser &data) {
fillMessagePeer(fullId, peerFromUser(data.vuser_id()));
}, [](const auto &) {
});
}, [](const MTPDmessageEmpty &) {
});
}
void Session::fillMessagePeers(const MTPDupdateShortMessage &data) {
const auto id = MsgId(data.vid().v);
const auto peerId = peerFromUser(data.vuser_id());
if (!id || !peerId) {
return;
}
const auto fullId = FullMsgId(peerId, id);
const auto fill = [&](PeerId peerId) {
if (!peerLoaded(peerId)) {
_messagesWithPeer[peerId].push_back(fullId);
}
};
const auto fillForwardedInfo = [&](const MTPMessageFwdHeader &header) {
return header.match([&](const MTPDmessageFwdHeader &data) {
if (const auto fromId = data.vfrom_id()) {
fill(peerFromMTP(*fromId));
}
});
};
const auto fillMentionUsers = [&](
const MTPVector<MTPMessageEntity> &entities) {
for (const auto &entity : entities.v) {
entity.match([&](const MTPDmessageEntityMentionName &data) {
fill(peerFromUser(data.vuser_id()));
}, [&](const MTPDinputMessageEntityMentionName &data) {
data.vuser_id().match([&](const MTPDinputUser &data) {
fill(peerFromUser(data.vuser_id()));
}, [](const auto &) {});
}, [](const auto &) {});
}
};
return message.match([&](const MTPDmessage &message) {
if (const auto fromId = message.vfrom_id()) {
fill(peerFromMTP(*fromId));
}
if (const auto viaBotId = message.vvia_bot_id()) {
fill(peerFromUser(*viaBotId));
}
if (const auto fwd = message.vfwd_from()) {
fillForwardedInfo(*fwd);
}
if (const auto entities = message.ventities()) {
fillMentionUsers(*entities);
}
}, [&](const MTPDmessageService &message) {
if (const auto fromId = message.vfrom_id()) {
fill(peerFromMTP(*fromId));
}
return message.vaction().match(
[&](const MTPDmessageActionChatAddUser &action) {
for (const auto &userId : action.vusers().v) {
fill(peerFromUser(userId));
}
}, [&](const MTPDmessageActionChatJoinedByLink &action) {
fill(peerFromUser(action.vinviter_id()));
}, [&](const MTPDmessageActionChatDeleteUser &action) {
fill(peerFromUser(action.vuser_id()));
}, [](const auto &) {
});
}, [](const MTPDmessageEmpty &message) {
});
fillMessagePeer(fullId, peerId);
if (const auto viaBotId = data.vvia_bot_id()) {
fillMessagePeer(fullId, peerFromUser(*viaBotId));
}
if (const auto fwd = data.vfwd_from()) {
fillForwardedInfo(fullId, *fwd);
}
if (const auto entities = data.ventities()) {
fillMentionUsers(fullId, *entities);
}
}
void Session::fillMessagePeers(const MTPDupdateShortChatMessage &data) {
const auto id = MsgId(data.vid().v);
const auto peerId = peerFromChat(data.vchat_id());
if (!id || !peerId) {
return;
}
const auto fullId = FullMsgId(peerId, id);
fillMessagePeer(fullId, peerId);
fillMessagePeer(fullId, peerFromUser(data.vfrom_id()));
if (const auto viaBotId = data.vvia_bot_id()) {
fillMessagePeer(fullId, peerFromUser(*viaBotId));
}
if (const auto fwd = data.vfwd_from()) {
fillForwardedInfo(fullId, *fwd);
}
if (const auto entities = data.ventities()) {
fillMentionUsers(fullId, *entities);
}
}
void Session::fillMessagePeers(
FullMsgId fullId,
const MTPDupdateShortSentMessage &data) {
if (const auto entities = data.ventities()) {
fillMentionUsers(fullId, *entities);
}
}
HistoryItem *Session::messageWithPeer(PeerId id) const {
if (id == _session->userPeerId()) {
return nullptr;
}
const auto i = _messagesWithPeer.find(id);
if (i == end(_messagesWithPeer)) {
return nullptr;

View File

@@ -918,7 +918,12 @@ public:
void clearLocalStorage();
void fillMessagePeers(const MTPMessage &message);
void fillMessagePeers(PeerId peerId, const MTPMessage &message);
void fillMessagePeers(const MTPDupdateShortMessage &data);
void fillMessagePeers(const MTPDupdateShortChatMessage &data);
void fillMessagePeers(
FullMsgId fullId,
const MTPDupdateShortSentMessage &data);
[[nodiscard]] HistoryItem *messageWithPeer(PeerId id) const;
private:
@@ -1065,6 +1070,14 @@ private:
void checkPollsClosings();
void fillMessagePeer(FullMsgId fullId, PeerId peerId);
void fillForwardedInfo(
FullMsgId fullId,
const MTPMessageFwdHeader &header);
void fillMentionUsers(
FullMsgId fullId,
const MTPVector<MTPMessageEntity> &entities);
const not_null<Main::Session*> _session;
Storage::DatabasePointer _cache;

View File

@@ -137,7 +137,7 @@ rpl::producer<MyGiftsDescriptor> MyUniqueGiftsSlice(
| ((type == MyUniqueType::OnlyOwned)
? Flag::f_exclude_hosted
: Flag())),
user->input,
user->input(),
MTP_int(0), // collection_id
MTP_string(offset),
MTP_int(kMyGiftsPerPage)

View File

@@ -332,7 +332,7 @@ void Stories::requestPeerStories(
}
};
_owner->session().api().request(MTPstories_GetPeerStories(
peer->input
peer->input()
)).done([=](const MTPstories_PeerStories &result) {
const auto &data = result.data();
_owner->processUsers(data.vusers());
@@ -849,7 +849,7 @@ void Stories::sendResolveRequests() {
};
const auto peer = _owner->session().data().peer(peerId);
api->request(MTPstories_GetStoriesByID(
peer->input,
peer->input(),
MTP_vector<MTPint>(prepared)
)).done([=](const MTPstories_Stories &result) {
owner().processUsers(result.data().vusers());
@@ -1090,7 +1090,7 @@ void Stories::sendReaction(FullStoryId id, Data::ReactionId reaction) {
const auto api = &session().api();
api->request(MTPstories_SendReaction(
MTP_flags(0),
story->peer()->input,
story->peer()->input(),
MTP_int(id.story),
ReactionToMTP(reaction)
)).send();
@@ -1317,7 +1317,7 @@ void Stories::toggleHidden(
peer->setStoriesHidden(hidden);
}
session().api().request(MTPstories_TogglePeerStoriesHidden(
peer->input,
peer->input(),
MTP_bool(hidden)
)).send();
if (byHints) {
@@ -1400,7 +1400,7 @@ void Stories::sendMarkAsReadRequest(
const auto api = &_owner->session().api();
api->request(MTPstories_ReadStories(
peer->input,
peer->input(),
MTP_int(tillId)
)).done(finish).fail(finish).send();
}
@@ -1461,7 +1461,7 @@ void Stories::sendIncrementViewsRequests() {
checkQuitPreventFinished();
};
api->request(MTPstories_IncrementStoryViews(
_owner->peer(peer)->input,
_owner->peer(peer)->input(),
MTP_vector<MTPint>(std::move(ids))
)).done(finish).fail(finish).send();
_incrementViewsPending.remove(peer);
@@ -1521,7 +1521,7 @@ void Stories::loadReactionsSlice(
_owner->session().api().request(_reactionsRequestId).cancel();
_reactionsRequestId = api->request(MTPstories_GetStoryReactionsList(
MTP_flags(offset.isEmpty() ? Flag() : Flag::f_offset),
_reactionsStoryPeer->input,
_reactionsStoryPeer->input(),
MTP_int(_reactionsStoryId),
MTPReaction(),
MTP_string(_reactionsOffset),
@@ -1595,7 +1595,7 @@ void Stories::sendViewsSliceRequest() {
_owner->session().api().request(_viewsRequestId).cancel();
_viewsRequestId = api->request(MTPstories_GetStoryViewsList(
MTP_flags(Flag::f_reactions_first),
_viewsStoryPeer->input,
_viewsStoryPeer->input(),
MTPstring(), // q
MTP_int(_viewsStoryId),
MTP_string(_viewsOffset),
@@ -1671,7 +1671,7 @@ void Stories::sendViewsCountsRequest() {
const auto api = &_owner->session().api();
_owner->session().api().request(_viewsRequestId).cancel();
_viewsRequestId = api->request(MTPstories_GetStoriesViews(
_viewsStoryPeer->input,
_viewsStoryPeer->input(),
MTP_vector<MTPint>(1, MTP_int(_viewsStoryId))
)).done([=](const MTPstories_StoryViews &result) {
_viewsRequestId = 0;
@@ -1843,18 +1843,18 @@ void Stories::albumIdsLoadMore(PeerId peerId, int albumId, bool reload) {
};
set->requestId = (albumId == kStoriesAlbumIdArchive)
? api->request(MTPstories_GetStoriesArchive(
peer->input,
peer->input(),
MTP_int(set->lastId),
MTP_int(set->lastId ? kArchivePerPage : kArchiveFirstPerPage)
)).done(done).fail(fail).send()
: (albumId == kStoriesAlbumIdSaved)
? api->request(MTPstories_GetPinnedStories(
peer->input,
peer->input(),
MTP_int(set->lastId),
MTP_int(set->lastId ? kSavedPerPage : kSavedFirstPerPage)
)).done(done).fail(fail).send()
: api->request(MTPstories_GetAlbumStories(
peer->input,
peer->input(),
MTP_int(albumId),
MTP_int(reload ? 0 : set->ids.list.size()),
MTP_int((reload || set->ids.list.empty())
@@ -1891,7 +1891,7 @@ void Stories::loadAlbums(not_null<PeerData*> peer, Albums &albums) {
const auto api = &_owner->session().api();
api->request(base::take(albums.requestId)).cancel();
albums.requestId = api->request(MTPstories_GetAlbums(
peer->input,
peer->input(),
MTP_long(albums.hash)
)).done([=](const MTPstories_Albums &result) {
auto &albums = _albums[peer->id];
@@ -1925,7 +1925,7 @@ void Stories::albumCreate(
ids.push_back(MTP_int(addId));
}
_owner->session().api().request(MTPstories_CreateAlbum(
peer->input,
peer->input(),
MTP_string(title),
MTP_vector<MTPint>(ids)
)).done([=](const MTPStoryAlbum &result) {
@@ -1954,7 +1954,7 @@ void Stories::albumRename(
using Flag = MTPstories_UpdateAlbum::Flag;
_owner->session().api().request(MTPstories_UpdateAlbum(
MTP_flags(Flag::f_title),
peer->input,
peer->input(),
MTP_int(id),
MTP_string(title),
MTPVector<MTPint>(),
@@ -1979,7 +1979,7 @@ void Stories::albumRename(
void Stories::albumDelete(not_null<PeerData*> peer, int id) {
_owner->session().api().request(MTPstories_DeleteAlbum(
peer->input,
peer->input(),
MTP_int(id)
)).send();
@@ -2039,7 +2039,7 @@ void Stories::albumReorderStories(
_reorderStoriesRequestId = _owner->session().api().request(
MTPstories_UpdateAlbum(
MTP_flags(MTPstories_UpdateAlbum::Flag::f_order),
peer->input,
peer->input(),
MTP_int(albumId),
MTPstring(),
MTPVector<MTPint>(),
@@ -2134,7 +2134,7 @@ void Stories::deleteList(const std::vector<FullStoryId> &ids) {
}
const auto api = &_owner->session().api();
api->request(MTPstories_DeleteStories(
peer->input,
peer->input(),
MTP_vector<MTPint>(list)
)).done([=](const MTPVector<MTPint> &result) {
for (const auto &id : result.v) {
@@ -2162,7 +2162,7 @@ void Stories::toggleInProfileList(
}
const auto api = &_owner->session().api();
api->request(MTPstories_TogglePinned(
peer->input,
peer->input(),
MTP_vector<MTPint>(list),
MTP_bool(inProfile)
)).done([=](const MTPVector<MTPint> &result) {
@@ -2265,7 +2265,7 @@ void Stories::togglePinnedList(
const auto api = &_owner->session().api();
const auto peer = session().data().peer(peerId);
api->request(MTPstories_TogglePinnedToTop(
peer->input,
peer->input(),
MTP_vector<MTPint>(list)
)).done([=] {
setPinnedToTop(peerId, list

View File

@@ -168,7 +168,7 @@ public:
void madeAction(TimeId when); // pseudo-online
uint64 accessHash() const {
[[nodiscard]] uint64 accessHash() const {
return _accessHash;
}
void setAccessHash(uint64 accessHash);

View File

@@ -80,7 +80,7 @@ NotifySettings::NotifySettings(not_null<Session*> owner)
void NotifySettings::request(not_null<PeerData*> peer) {
if (peer->notify().settingsUnknown()) {
peer->session().api().requestNotifySettings(
MTP_inputNotifyPeer(peer->input));
MTP_inputNotifyPeer(peer->input()));
}
if (defaultSettings(peer).settingsUnknown()) {
peer->session().api().requestNotifySettings(peer->isUser()
@@ -96,7 +96,7 @@ void NotifySettings::request(not_null<Thread*> thread) {
if (topic->notify().settingsUnknown()) {
topic->session().api().requestNotifySettings(
MTP_inputNotifyForumTopic(
topic->peer()->input,
topic->peer()->input(),
MTP_int(topic->rootId())));
}
}