diff options
Diffstat (limited to 'lib/user.cpp')
-rw-r--r-- | lib/user.cpp | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/lib/user.cpp b/lib/user.cpp index c97e33a4..88549e5d 100644 --- a/lib/user.cpp +++ b/lib/user.cpp @@ -65,7 +65,8 @@ User::~User() = default; void User::load() { - auto *profileJob = connection()->callApi<GetUserProfileJob>(id()); + auto* profileJob = + connection()->callApi<GetUserProfileJob>(QUrl::toPercentEncoding(id())); connect(profileJob, &BaseJob::result, this, [this, profileJob] { d->defaultName = profileJob->displayname(); d->defaultAvatar = Avatar(QUrl(profileJob->avatarUrl())); @@ -81,7 +82,7 @@ bool User::isGuest() const Q_ASSERT(!d->id.isEmpty() && d->id.startsWith('@')); auto it = std::find_if_not(d->id.cbegin() + 1, d->id.cend(), [](QChar c) { return c.isDigit(); }); - Q_ASSERT(it != d->id.end()); + Q_ASSERT(it != d->id.cend()); return *it == ':'; } @@ -92,8 +93,6 @@ QString User::name(const Room* room) const return room ? room->memberName(id()) : d->defaultName; } -QString User::rawName(const Room* room) const { return name(room); } - void User::rename(const QString& newName) { const auto actualNewName = sanitized(newName); @@ -134,17 +133,17 @@ template <typename SourceT> inline bool User::doSetAvatar(SourceT&& source) { return d->defaultAvatar.upload( - connection(), source, [this](const QString& contentUri) { + connection(), source, [this](const QUrl& contentUri) { auto* j = connection()->callApi<SetAvatarUrlJob>(id(), contentUri); connect(j, &BaseJob::success, this, - [this, newUrl = QUrl(contentUri)] { - if (newUrl == d->defaultAvatar.url()) { - d->defaultAvatar.updateUrl(newUrl); + [this, contentUri] { + if (contentUri == d->defaultAvatar.url()) { + d->defaultAvatar.updateUrl(contentUri); emit defaultAvatarChanged(); } else qCWarning(MAIN) << "User" << id() << "already has avatar URL set to" - << newUrl.toDisplayString(); + << contentUri.toDisplayString(); }); }); } @@ -161,7 +160,7 @@ bool User::setAvatar(QIODevice* source) void User::removeAvatar() { - connection()->callApi<SetAvatarUrlJob>(id(), ""); + connection()->callApi<SetAvatarUrlJob>(id(), QUrl()); } void User::requestDirectChat() { connection()->requestDirectChat(this); } @@ -184,8 +183,6 @@ QString User::fullName(const Room* room) const return displayName.isEmpty() ? id() : (displayName % " (" % id() % ')'); } -QString User::bridged() const { return {}; } - const Avatar& User::avatarObject(const Room* room) const { if (!room) @@ -196,18 +193,18 @@ const Avatar& User::avatarObject(const Room* room) const return d->otherAvatars.try_emplace(mediaId, url).first->second; } -QImage User::avatar(int dimension, const Room* room) +QImage User::avatar(int dimension, const Room* room) const { return avatar(dimension, dimension, room); } -QImage User::avatar(int width, int height, const Room* room) +QImage User::avatar(int width, int height, const Room* room) const { return avatar(width, height, room, [] {}); } QImage User::avatar(int width, int height, const Room* room, - const Avatar::get_callback_t& callback) + const Avatar::get_callback_t& callback) const { return avatarObject(room).get(connection(), width, height, callback); } |