aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2021-07-14 19:55:46 +0200
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2021-07-14 19:55:46 +0200
commit3d2af27dbba9bf9de238002cb64d6f8046a25a2b (patch)
tree5a47704da20d36a581edf88afc1f21d1e0c824d2 /lib
parent5a200039d6a34815b29c4a918bca8fa451c61f45 (diff)
downloadlibquotient-3d2af27dbba9bf9de238002cb64d6f8046a25a2b.tar.gz
libquotient-3d2af27dbba9bf9de238002cb64d6f8046a25a2b.zip
User::rename(): actually build on the current state
This is a further extension of #481 fix that takes the whole current state event content, rather than just the avatar URL.
Diffstat (limited to 'lib')
-rw-r--r--lib/user.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/user.cpp b/lib/user.cpp
index 7143620f..f0831733 100644
--- a/lib/user.cpp
+++ b/lib/user.cpp
@@ -171,13 +171,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;
- // #481: fill in the current avatar URL in order to not clear it out
- evtC.avatarUrl = r->getCurrentState<RoomMemberEvent>(id())->avatarUrl();
+ evtC.displayName = sanitized(newName);
r->setState<RoomMemberEvent>(id(), move(evtC));
// The state will be updated locally after it arrives with sync
}