-
Notifications
You must be signed in to change notification settings - Fork 807
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
Add push notifications for file changes #2814
Conversation
b2cf7ee
to
8e23481
Compare
faac21c
to
171efad
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple more things:
- commit style wise, I'd have made this in three commits: one for the credentials changes, one for the capabilities additions and one for wiring the new capability to the websocket and folderman;
- design wise, I think it'd make sense to move the websocket out of AccountState and instead add a new class PushNotification which would be constructed with an Account object, this would help wrapping almost all the push notification related code in its own class, this would also allow to have that new class in libsync and so potentially easier to test, then AccountState could decide to construct an instance of it and expose it to the outside if the capability is there.
You mean the PushNotification object should be constructed if a AccountState object is constructed not an Account object? |
Indeed I was unclear. What I meant is: the AccountState object makes the decision to construct PushNotification or not, also PushNotification receives an Account object as parameter during construction. |
src/libsync/capabilities.cpp
Outdated
@@ -176,6 +176,25 @@ bool Capabilities::chunkingNg() const | |||
return _capabilities["dav"].toMap()["chunking"].toByteArray() >= "1.0"; | |||
} | |||
|
|||
PushNotificationTypes Capabilities::pushNotificationsAvailable() const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@er-vin @felixboehm
I don't know why, but, for me, when I see this PushNotificationTypes it makes me think of PushNotificationTypes as some sort of aggregate, while in fact, it's just an enum. I've immediately started to look for push_back() or insert().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its's some sort of aggregate I think. It can hold multiple flags. How would you name it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@FlexW Got no idea right now :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fairly common in my experience to have a singular for the enum and a plural for the corresponding flag. Now admittedly a "Types" flag is less common because in our minds types tend to be mutually exclusive (you're either of a type or of another not of two types). There are precedent though (qtbase alone has three such "Types" flags).
If we're concerned that "Types" could create confusion potential alternatives (not saying we should change, but just in case we do change then we got ideas): PushNotificationAreas, PushNotificationDomains, PushNotificationChannels (with the backing enum being respectively PushNotificationArea, PushNotificationDomain and PushNotificationChannel of course).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I will leave it as it is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be clear: I'm personally fine with it.
Now I can understand if it's unclear for someone else, which is what @allexzander expressed hence why I made proposals for alternative names.
@allexzander should @FlexW go for one of the proposals I made? Or we stay with "Types"?
src/libsync/pushnotifications.cpp
Outdated
|
||
void PushNotifications::onWebSocketSslErrors(const QList<QSslError> &errors) | ||
{ | ||
// TODO: What to do with them? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having a log here would be something, to begin with. Just to make sure, later if we have some weird issue happening on a customer's end, we could just request the logs without having to roll-out an update with logs added :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, that's what qWarning does, but it'd need to be a qCWarning. ;-)
Also should be treated like an auth error, we just bail out and go back to the timer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What exaclty does bail out and go back to the timer mean?
/rebase |
19135ba
to
692026c
Compare
test/testpushnotifications.cpp
Outdated
QCOMPARE(spy.count(), 2); | ||
const auto socket = spy.at(0).at(0).value<QWebSocket *>(); | ||
const auto firstPasswordSent = spy.at(1).at(1).toString(); | ||
QCOMPARE(firstPasswordSent, password); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: This comes back very often, what about factoring out the part related to waiting for the authentication out in a function? This way we could have some of the tests written from the perspective of an already setup PushNotifications object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that would make sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're really close now. Good job.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you didn't intend to push that latest commit, or?
The current version does now contain exactly what I have on my computer. You are welcome to try it yourself if you also get the authentication message but no other;) |
Thanks. I have now tested against |
Well, if they're fast enough that they are within the 2s delay after you trigger from the push notification they'll be caught by the sync anyway... if they occur during the sync we'd have scheduled another sync right after the ongoing one anyway, so I think it'd be fine. |
OK... Actually I was wrong, I thought I remember we were going through the sync scheduling mechanism but that's not the case... I'll add a comment in the code to potentially deal with this. |
src/gui/folderman.cpp
Outdated
} | ||
|
||
qCInfo(lcFolderMan) << "Run etag job if possible on " << folder; | ||
runEtagJobIfPossible(folder); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So indeed we could have an issue there, if the folder is syncing already or blocked by another one we might loose the event. This is both good and bad. Good because it avoids syncing too many times for nothing if you receive a burst of such notifications, bad because you might miss a change (I'd say chances are slim but will increase with the amount of files in the folder).
I think we might want to call scheduleFolder
or scheduleFolderNext
here instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would go for scheduleFolder()
because it does not add the folder to the queue if it's already added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds fine.
5bdb07e
to
581a4a7
Compare
6d8e9d9
to
1282657
Compare
/rebase |
Resolves #2802 Signed-off-by: Felix Weilbach <felix.weilbach@nextcloud.com>
1282657
to
78f00ac
Compare
AppImage file: Nextcloud-PR-2814-78f00acaa2683cf983738c3194503ad40b9df689-x86_64.AppImage |
/backport to stable-3.1 |
No description provided.