diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-03-17 18:58:49 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-03-17 18:58:49 +0900 |
commit | 4a7e1a8c8a1940827ba9aea0bd830ef9dbf912ed (patch) | |
tree | ddfaffd931d3d17021f45a3690374e2990f4d302 /lib/user.cpp | |
parent | 6577320f8653fbd99a100a844d7b42a46da5f45a (diff) | |
download | libquotient-4a7e1a8c8a1940827ba9aea0bd830ef9dbf912ed.tar.gz libquotient-4a7e1a8c8a1940827ba9aea0bd830ef9dbf912ed.zip |
User: strip RLO/LRO markers on renaming as well
Continuation of work on #545.
Diffstat (limited to 'lib/user.cpp')
-rw-r--r-- | lib/user.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/user.cpp b/lib/user.cpp index eec41957..93cfbffd 100644 --- a/lib/user.cpp +++ b/lib/user.cpp @@ -264,8 +264,9 @@ void User::updateAvatarUrl(const QUrl& newUrl, const QUrl& oldUrl, void User::rename(const QString& newName) { - auto job = connection()->callApi<SetDisplayNameJob>(id(), newName); - connect(job, &BaseJob::success, this, [=] { updateName(newName); }); + const auto actualNewName = sanitized(newName); + connect(connection()->callApi<SetDisplayNameJob>(id(), actualNewName), + &BaseJob::success, this, [=] { updateName(actualNewName); }); } void User::rename(const QString& newName, const Room* r) @@ -279,10 +280,11 @@ void User::rename(const QString& newName, const Room* r) } Q_ASSERT_X(r->memberJoinState(this) == JoinState::Join, __FUNCTION__, "Attempt to rename a user that's not a room member"); + const auto actualNewName = sanitized(newName); MemberEventContent evtC; - evtC.displayName = newName; - auto job = r->setMemberState(id(), RoomMemberEvent(move(evtC))); - connect(job, &BaseJob::success, this, [=] { updateName(newName, r); }); + evtC.displayName = actualNewName; + connect(r->setMemberState(id(), RoomMemberEvent(move(evtC))), + &BaseJob::success, this, [=] { updateName(actualNewName, r); }); } bool User::setAvatar(const QString& fileName) |