diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index 7982aed250..0ef84b322a 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -209,6 +209,27 @@ ApiWrap::ApiWrap(not_null session) ApiWrap::~ApiWrap() = default; +void ApiWrap::ProcessRecentSelfForwards( + not_null session, + const MTPUpdates &updates, + PeerId targetPeerId, + PeerId fromPeerId) { + auto newIds = MessageIdsList(); + updates.match([&](const MTPDupdates &data) { + for (const auto &update : data.vupdates().v) { + update.match([&](const MTPDupdateMessageID &d) { + newIds.push_back(FullMsgId(targetPeerId, d.vid().v)); + }, [](const auto &) {}); + } + }, [](const auto &) {}); + if (!newIds.empty()) { + session->data().addRecentSelfForwards({ + .fromPeerId = fromPeerId, + .ids = newIds, + }); + } +} + Main::Session &ApiWrap::session() const { return *_session; } @@ -3524,21 +3545,11 @@ void ApiWrap::forwardMessages( } finish(); if (peer->isSelf() && session().premium()) { - auto newIds = MessageIdsList(); - result.match([&](const MTPDupdates &data) { - for (const auto &update : data.vupdates().v) { - update.match([&](const MTPDupdateMessageID &d) { - newIds.push_back( - FullMsgId(peer->id, d.vid().v)); - }, [](const auto &) {}); - } - }, [](const auto &) {}); - if (!newIds.empty()) { - session().data().addRecentSelfForwards({ - .fromPeerId = forwardFrom->id, - .ids = newIds, - }); - } + ProcessRecentSelfForwards( + _session, + result, + peer->id, + forwardFrom->id); } }).fail([=](const MTP::Error &error) { if (idsCopy) { diff --git a/Telegram/SourceFiles/apiwrap.h b/Telegram/SourceFiles/apiwrap.h index f671545331..4f78924b9d 100644 --- a/Telegram/SourceFiles/apiwrap.h +++ b/Telegram/SourceFiles/apiwrap.h @@ -432,6 +432,12 @@ public: static constexpr auto kJoinErrorDuration = 5 * crl::time(1000); + static void ProcessRecentSelfForwards( + not_null session, + const MTPUpdates &updates, + PeerId targetPeerId, + PeerId fromPeerId); + private: struct MessageDataRequest { using Callbacks = std::vector>;