diff options
author | Erik Verbruggen <erik@verbruggen.consulting> | 2021-10-06 18:52:18 +0300 |
---|---|---|
committer | Hannah von Reth <vonreth@kde.org> | 2021-10-07 17:29:54 +0300 |
commit | 88c4661d7d8beaa39b2d37636d14fd179c721507 (patch) | |
tree | e52e95b311c102158a850d0b3e11cfcaf274117d /src/gui/connectionvalidator.cpp | |
parent | 35d059e2875732696b0bc6a164cb90f45c56e40a (diff) |
Do not try to (repeatedly) fetch profile pictures when not available
The server has a capability to indicate that profile pictures (avatars)
are not available. Previously, the client would try to fetch them no
matter what, and even retry when the server responded with a 404. Now
we take the server capability into account, and do not try to fetch
those when not available.
Fixes: #8758
Diffstat (limited to 'src/gui/connectionvalidator.cpp')
-rw-r--r-- | src/gui/connectionvalidator.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/gui/connectionvalidator.cpp b/src/gui/connectionvalidator.cpp index e9e0754c6..88479cf09 100644 --- a/src/gui/connectionvalidator.cpp +++ b/src/gui/connectionvalidator.cpp @@ -286,14 +286,24 @@ void ConnectionValidator::slotUserFetched(const QJsonDocument &json) if (!displayName.isEmpty()) { _account->setDavDisplayName(displayName); } + + auto capabilities = _account->capabilities(); + // We should have received the capabilities by now. Check that assumption in a debug build. If + // it's not the case, the code below will assume that they are not available. + Q_ASSERT(capabilities.isValid()); + #ifndef TOKEN_AUTH_ONLY - AvatarJob *job = new AvatarJob(_account, _account->davUser(), 128, this); - job->setTimeout(20 * 1000); - QObject::connect(job, &AvatarJob::avatarPixmap, this, &ConnectionValidator::slotAvatarImage); - job->start(); -#else - reportResult(Connected); + if (capabilities.isValid() && capabilities.avatarsAvailable()) { + AvatarJob *job = new AvatarJob(_account, _account->davUser(), 128, this); + job->setTimeout(20 * 1000); + QObject::connect(job, &AvatarJob::avatarPixmap, this, &ConnectionValidator::slotAvatarImage); + job->start(); + // reportResult will be called when the avatar has been received by `slotAvatarImage` + } else #endif + { + reportResult(Connected); + } } #ifndef TOKEN_AUTH_ONLY |