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-24 19:08:20 +0900 |
commit | e2dea5a7e263707c283b63f0c31b4fae8399db3b (patch) | |
tree | 204a4e4085597ed019d042e89d0ab89147caef88 | |
parent | e855085835909549aa866ed968e24902eb378b5a (diff) | |
download | libquotient-e2dea5a7e263707c283b63f0c31b4fae8399db3b.tar.gz libquotient-e2dea5a7e263707c283b63f0c31b4fae8399db3b.zip |
User: strip RLO/LRO markers on renaming as well
Continuation of work on #545.
-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) |