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 currentRoom;
|
||||
bool firstMessagesCall = true;
|
||||
std::uint64_t currentRoomCount = 0;
|
||||
std::string currentRoomPrevToken;
|
||||
std::set<std::pair<std::string, std::string>> currentRoomStateEvents;
|
||||
|
@ -1685,6 +1686,13 @@ utils::removeExpiredEvents()
|
|||
}
|
||||
});
|
||||
} 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{};
|
||||
opts.dir = mtx::http::PaginationDirection::Backwards;
|
||||
opts.from = state->currentRoomPrevToken;
|
||||
|
@ -1692,16 +1700,20 @@ utils::removeExpiredEvents()
|
|||
opts.filter = state->filter;
|
||||
opts.room_id = state->currentRoom;
|
||||
|
||||
state->firstMessagesCall = false;
|
||||
|
||||
http::client()->messages(
|
||||
opts,
|
||||
[state = std::move(state)](const mtx::responses::Messages &msgs,
|
||||
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->currentRoomCount = 0;
|
||||
} else if (msgs.chunk.empty()) {
|
||||
state->currentRoomPrevToken.clear();
|
||||
} else {
|
||||
if (!msgs.end.empty())
|
||||
state->currentRoomPrevToken = msgs.end;
|
||||
|
||||
auto now = (uint64_t)QDateTime::currentMSecsSinceEpoch();
|
||||
|
@ -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));
|
||||
});
|
||||
} else if (!state->roomsToUpdate.empty()) {
|
||||
|
@ -1795,6 +1800,12 @@ utils::removeExpiredEvents()
|
|||
state->currentRoom = room;
|
||||
state->currentExpiry = state->globalExpiry->content;
|
||||
}
|
||||
state->firstMessagesCall = true;
|
||||
state->currentRoomCount = 0;
|
||||
state->currentRoomPrevToken = "";
|
||||
state->currentRoomRedactionQueue.clear();
|
||||
state->currentRoomStateEvents.clear();
|
||||
|
||||
state->roomsToUpdate.pop_back();
|
||||
next(std::move(state));
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue