aboutsummaryrefslogtreecommitdiff
path: root/lib/user.cpp
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2021-07-16 22:11:27 +0200
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2021-07-16 22:11:27 +0200
commitd85c63ffaf776683a74d0a20dcdb76f7ade8461b (patch)
tree9bc8e491186a7e6f1db81da7439fa7a884e09218 /lib/user.cpp
parent680d51c4686ab5645405a0ca9631b71a567eaefa (diff)
downloadlibquotient-d85c63ffaf776683a74d0a20dcdb76f7ade8461b.tar.gz
libquotient-d85c63ffaf776683a74d0a20dcdb76f7ade8461b.zip
User::rename(): don't discard the current state
Closes #481.
Diffstat (limited to 'lib/user.cpp')
-rw-r--r--lib/user.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/user.cpp b/lib/user.cpp
index 7933c5d9..6cc9e161 100644
--- a/lib/user.cpp
+++ b/lib/user.cpp
@@ -121,11 +121,11 @@ void User::rename(const QString& newName, const Room* r)
rename(newName);
return;
}
- Q_ASSERT_X(r->memberJoinState(this) == JoinState::Join, __FUNCTION__,
+ // #481: take the current state and update it with the new name
+ auto evtC = r->getCurrentState<RoomMemberEvent>(id())->content();
+ Q_ASSERT_X(evtC.membership == MembershipType::Join, __FUNCTION__,
"Attempt to rename a user that's not a room member");
- const auto actualNewName = sanitized(newName);
- MemberEventContent evtC;
- evtC.displayName = actualNewName;
+ evtC.displayName = sanitized(newName);
r->setState<RoomMemberEvent>(id(), move(evtC));
// The state will be updated locally after it arrives with sync
}