Moved out api processing of recent self forwards to single place.

This commit is contained in:
23rd
2025-10-07 19:34:00 +03:00
parent 338183e647
commit acf61c24bd
2 changed files with 32 additions and 15 deletions
+26 -15
View File
@@ -209,6 +209,27 @@ ApiWrap::ApiWrap(not_null<Main::Session*> session)
ApiWrap::~ApiWrap() = default;
void ApiWrap::ProcessRecentSelfForwards(
not_null<Main::Session*> 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) {
+6
View File
@@ -432,6 +432,12 @@ public:
static constexpr auto kJoinErrorDuration = 5 * crl::time(1000);
static void ProcessRecentSelfForwards(
not_null<Main::Session*> session,
const MTPUpdates &updates,
PeerId targetPeerId,
PeerId fromPeerId);
private:
struct MessageDataRequest {
using Callbacks = std::vector<Fn<void()>>;