mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Fix event expiration not always stopping properly and redacting some wrong state events
This commit is contained in:
parent
6c180a5ca3
commit
5f8e80cd84
1 changed files with 22 additions and 11 deletions
|
@ -1642,6 +1642,7 @@ utils::removeExpiredEvents()
|
||||||
std::string filter;
|
std::string filter;
|
||||||
|
|
||||||
std::string currentRoom;
|
std::string currentRoom;
|
||||||
|
bool firstMessagesCall = true;
|
||||||
std::uint64_t currentRoomCount = 0;
|
std::uint64_t currentRoomCount = 0;
|
||||||
std::string currentRoomPrevToken;
|
std::string currentRoomPrevToken;
|
||||||
std::set<std::pair<std::string, std::string>> currentRoomStateEvents;
|
std::set<std::pair<std::string, std::string>> currentRoomStateEvents;
|
||||||
|
@ -1685,6 +1686,13 @@ utils::removeExpiredEvents()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (!state->currentRoom.empty()) {
|
} else if (!state->currentRoom.empty()) {
|
||||||
|
if (state->currentRoomPrevToken.empty() && !state->firstMessagesCall) {
|
||||||
|
nhlog::net()->info("Finished room {}", state->currentRoom);
|
||||||
|
state->currentRoom.clear();
|
||||||
|
next(std::move(state));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
mtx::http::MessagesOpts opts{};
|
mtx::http::MessagesOpts opts{};
|
||||||
opts.dir = mtx::http::PaginationDirection::Backwards;
|
opts.dir = mtx::http::PaginationDirection::Backwards;
|
||||||
opts.from = state->currentRoomPrevToken;
|
opts.from = state->currentRoomPrevToken;
|
||||||
|
@ -1692,17 +1700,21 @@ utils::removeExpiredEvents()
|
||||||
opts.filter = state->filter;
|
opts.filter = state->filter;
|
||||||
opts.room_id = state->currentRoom;
|
opts.room_id = state->currentRoom;
|
||||||
|
|
||||||
|
state->firstMessagesCall = false;
|
||||||
|
|
||||||
http::client()->messages(
|
http::client()->messages(
|
||||||
opts,
|
opts,
|
||||||
[state = std::move(state)](const mtx::responses::Messages &msgs,
|
[state = std::move(state)](const mtx::responses::Messages &msgs,
|
||||||
mtx::http::RequestErr error) mutable {
|
mtx::http::RequestErr error) mutable {
|
||||||
if (error || msgs.chunk.empty()) {
|
if (error) {
|
||||||
|
// skip success handler
|
||||||
|
nhlog::net()->info(
|
||||||
|
"Finished room {} with error {}", state->currentRoom, *error);
|
||||||
state->currentRoom.clear();
|
state->currentRoom.clear();
|
||||||
state->currentRoomCount = 0;
|
} else if (msgs.chunk.empty()) {
|
||||||
state->currentRoomPrevToken.clear();
|
state->currentRoomPrevToken.clear();
|
||||||
} else {
|
} else {
|
||||||
if (!msgs.end.empty())
|
state->currentRoomPrevToken = msgs.end;
|
||||||
state->currentRoomPrevToken = msgs.end;
|
|
||||||
|
|
||||||
auto now = (uint64_t)QDateTime::currentMSecsSinceEpoch();
|
auto now = (uint64_t)QDateTime::currentMSecsSinceEpoch();
|
||||||
auto us = http::client()->user_id().to_string();
|
auto us = http::client()->user_id().to_string();
|
||||||
|
@ -1775,13 +1787,6 @@ utils::removeExpiredEvents()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msgs.end.empty() && state->currentRoomRedactionQueue.empty()) {
|
|
||||||
state->currentRoom.clear();
|
|
||||||
state->currentRoomCount = 0;
|
|
||||||
state->currentRoomPrevToken.clear();
|
|
||||||
state->currentRoomStateEvents.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
next(std::move(state));
|
next(std::move(state));
|
||||||
});
|
});
|
||||||
} else if (!state->roomsToUpdate.empty()) {
|
} else if (!state->roomsToUpdate.empty()) {
|
||||||
|
@ -1795,6 +1800,12 @@ utils::removeExpiredEvents()
|
||||||
state->currentRoom = room;
|
state->currentRoom = room;
|
||||||
state->currentExpiry = state->globalExpiry->content;
|
state->currentExpiry = state->globalExpiry->content;
|
||||||
}
|
}
|
||||||
|
state->firstMessagesCall = true;
|
||||||
|
state->currentRoomCount = 0;
|
||||||
|
state->currentRoomPrevToken = "";
|
||||||
|
state->currentRoomRedactionQueue.clear();
|
||||||
|
state->currentRoomStateEvents.clear();
|
||||||
|
|
||||||
state->roomsToUpdate.pop_back();
|
state->roomsToUpdate.pop_back();
|
||||||
next(std::move(state));
|
next(std::move(state));
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue