Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure we do not renotify notifications when we have received the same etag as during the last check #6970

Merged
merged 2 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/gui/tray/notificationhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@
return;
}

// In theory the server should five us a 304 Not Modified if there are no new notifications.
// But in practice, the server doesn't always do that. So we need to compare the ETag headers.
const auto postFetchEtagHeader = _accountState->notificationsEtagResponseHeader();
if (!_preFetchEtagHeader.isEmpty() || _preFetchEtagHeader == postFetchEtagHeader) {
qCInfo(lcServerNotification) << "Notifications ETag header is the same as before, no new notifications.";
deleteLater();
emit jobFinished();

Check warning on line 87 in src/gui/tray/notificationhandler.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/tray/notificationhandler.cpp:87:14 [modernize-use-trailing-return-type]

use a trailing return type for this function
return;
}
_preFetchEtagHeader = postFetchEtagHeader;

auto notifies = json.object().value("ocs").toObject().value("data").toArray();

auto *ai = qvariant_cast<AccountState *>(sender()->property(propertyAccountStateC));
Expand Down
1 change: 1 addition & 0 deletions src/gui/tray/notificationhandler.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef NOTIFICATIONHANDLER_H
#define NOTIFICATIONHANDLER_H

#include <QtCore>

Check failure on line 4 in src/gui/tray/notificationhandler.h

View workflow job for this annotation

GitHub Actions / build

src/gui/tray/notificationhandler.h:4:10 [clang-diagnostic-error]

'QtCore' file not found

#include "usermodel.h"

Expand Down Expand Up @@ -30,6 +30,7 @@
private:
QPointer<JsonApiJob> _notificationJob;
AccountState *_accountState;
QString _preFetchEtagHeader;
};
}

Expand Down
Loading