aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2021-06-07 07:55:23 +0200
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2021-06-07 07:55:23 +0200
commitf0c95397234d9f350e0f952dbe2b7bb652027b5f (patch)
tree61501d98caa0bcae982feaaddaddb9a4f6b2be4d /lib
parent006926dfe58557fdd5e4361ca88bcf5df1ec990c (diff)
downloadlibquotient-f0c95397234d9f350e0f952dbe2b7bb652027b5f.tar.gz
libquotient-f0c95397234d9f350e0f952dbe2b7bb652027b5f.zip
Connection::joinRoom() shouldn't enforce room state
This is an adjustment to the earlier fix of #471: if a join is immediately followed by a leave (e.g. from another client/bot - you can't do it programmatically from libQuotient) the sync may bring the room already in the Leave state; therefore `joinRoom` should not impose the state but rather ask `provideRoom` to create a `Join` room - just as it's designed when passed an empty `joinState`.
Diffstat (limited to 'lib')
-rw-r--r--lib/connection.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp
index 1ac439a3..853053bd 100644
--- a/lib/connection.cpp
+++ b/lib/connection.cpp
@@ -804,14 +804,14 @@ PostReceiptJob* Connection::postReceipt(Room* room, RoomEvent* event)
JoinRoomJob* Connection::joinRoom(const QString& roomAlias,
const QStringList& serverNames)
{
- auto job = callApi<JoinRoomJob>(roomAlias, serverNames);
- // Upon completion, ensure a room object in Join state is created
- // (or it might already be there due to a sync completing earlier).
- // finished() is used here instead of success() to overtake clients
- // that may add their own slots to finished().
+ auto* const job = callApi<JoinRoomJob>(roomAlias, serverNames);
+ // Upon completion, ensure a room object is created in case it hasn't come
+ // with a sync yet. If the room object is not there, provideRoom() will
+ // create it in Join state. finished() is used here instead of success()
+ // to overtake clients that may add their own slots to finished().
connect(job, &BaseJob::finished, this, [this, job] {
if (job->status().good())
- provideRoom(job->roomId(), JoinState::Join);
+ provideRoom(job->roomId());
});
return job;
}