content access denied error during discovery: verify server access

will trigger a check of the server connectivity in case of content
access denied reporting when listing folders during discovery

should allow discovering early that terms of service need to be signed

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
This commit is contained in:
Matthieu Gallien 2024-10-22 14:49:51 +02:00 коммит произвёл backportbot[bot]
Родитель 06f04965a0
Коммит 6c73e2986a
3 изменённых файлов: 43 добавлений и 0 удалений

Просмотреть файл

@ -229,6 +229,7 @@ private:
bool _waitingForNewCredentials = false;
QDateTime _timeOfLastETagCheck;
QPointer<ConnectionValidator> _connectionValidator;
TermsOfServiceChecker _termsOfServiceChecker;
QByteArray _notificationsEtagResponseHeader;
QByteArray _navigationAppsEtagResponseHeader;

Просмотреть файл

@ -42,7 +42,10 @@ ConnectionValidator::ConnectionValidator(AccountStatePtr accountState, const QSt
, _previousErrors(previousErrors)
, _accountState(accountState)
, _account(accountState->account())
, _termsOfServiceChecker(_account)
{
connect(&_termsOfServiceChecker, &TermsOfServiceChecker::done,
this, &ConnectionValidator::termsOfServiceCheckDone);
}
void ConnectionValidator::checkServerAndAuth()
@ -306,6 +309,11 @@ bool ConnectionValidator::setAndCheckServerVersion(const QString &version)
return true;
}
void ConnectionValidator::checkServerTermsOfService()
{
_termsOfServiceChecker.start();
}
void ConnectionValidator::slotUserFetched(UserInfo *userInfo)
{
if(userInfo) {

Просмотреть файл

@ -75,6 +75,37 @@ namespace OCC {
class UserInfo;
class TermsOfServiceChecker : public QObject
{
Q_OBJECT
Q_PROPERTY(bool needToSign READ needToSign NOTIFY needToSignChanged FINAL)
public:
explicit TermsOfServiceChecker(AccountPtr account,
QObject *parent = nullptr);
explicit TermsOfServiceChecker(QObject *parent = nullptr);
[[nodiscard]] bool needToSign() const;
public slots:
void start();
signals:
void needToSignChanged();
void done();
private slots:
void slotServerTermsOfServiceRecieved(const QJsonDocument &reply);
private:
void checkServerTermsOfService();
AccountPtr _account;
bool _needToSign = false;
};
class ConnectionValidator : public QObject
{
Q_OBJECT
@ -144,10 +175,13 @@ private:
*/
bool setAndCheckServerVersion(const QString &version);
void checkServerTermsOfService();
const QStringList _previousErrors;
QStringList _errors;
AccountStatePtr _accountState;
AccountPtr _account;
TermsOfServiceChecker _termsOfServiceChecker;
bool _isCheckingServerAndAuth = false;
void showSystrayErrorMessage();