mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Moved out api processing of recent self forwards to single place.
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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()>>;
|
||||
|
||||
Reference in New Issue
Block a user