improve logs of E2EE API to not pollute logs

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
This commit is contained in:
Matthieu Gallien 2022-10-27 13:13:21 +02:00 committed by Matthieu Gallien
parent 7fe6a3df78
commit f8fc720fbb

View file

@ -143,24 +143,27 @@ bool Capabilities::clientSideEncryptionAvailable() const
}
const auto version = properties.value(QStringLiteral("api-version"), "1.0").toByteArray();
qCInfo(lcServerCapabilities) << "E2EE API version:" << version;
const auto splittedVersion = version.split('.');
bool ok = false;
const auto major = !splittedVersion.isEmpty() ? splittedVersion.at(0).toInt(&ok) : 0;
if (!ok) {
qCWarning(lcServerCapabilities) << "Didn't understand version scheme (major), E2EE disabled";
qCWarning(lcServerCapabilities) << "Didn't understand version scheme (major), E2EE disabled" << version;
return false;
}
ok = false;
const auto minor = splittedVersion.size() > 1 ? splittedVersion.at(1).toInt(&ok) : 0;
if (!ok) {
qCWarning(lcServerCapabilities) << "Didn't understand version scheme (minor), E2EE disabled";
qCWarning(lcServerCapabilities) << "Didn't understand version scheme (minor), E2EE disabled" << version;
return false;
}
return major == 1 && minor >= 1;
const auto capabilityAvailable = (major == 1 && minor >= 1);
if (!capabilityAvailable) {
qCInfo(lcServerCapabilities) << "Incompatible E2EE API version:" << version;
}
return capabilityAvailable;
}
bool Capabilities::notificationsAvailable() const