-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Accept user share notification #30106
Conversation
To test you need to untick the new auto accept option in the admin settings for sharing |
0933bcf
to
2837e77
Compare
apps/files_sharing/lib/Notifier.php
Outdated
switch ($notification->getSubject()) { | ||
case 'local_share': | ||
$params = $notification->getSubjectParameters(); | ||
if ($params[0] !== $params[1] && $params[1] !== null) { |
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.
Theorically, only share notifications should reach this point, and we expect that all the share notifications to have 2 parameters. Taking this into account, I'm not sure if we should add additional checks here.
@@ -76,6 +79,7 @@ class Share implements \OCP\Share\IShare { | |||
public function __construct(IRootFolder $rootFolder, IUserManager $userManager) { | |||
$this->rootFolder = $rootFolder; | |||
$this->userManager = $userManager; | |||
$this->state = Constants::STATE_ACCEPTED; |
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'm not sure if setting "accepted" as default value for the state is a good idea. Maybe setting null as default and enforcing that the state has a valid value just before saving it in the DB is a better idea.
apps/files_sharing/lib/Notifier.php
Outdated
// TODO: discard if target user is not in target group any more | ||
|
||
switch ($notification->getSubject()) { | ||
case 'local_share': |
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 should move this block to a private function. If it's implemented as "case" I expect more cases (public shares, federated shares, etc) that will eventually be implemented. Those cases will follow what is implemented here, so there will be more big blocks increasing the lines of this function making it more difficult to read.
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.
this code is copied from the Notifier in the federatedfileshare app which has "remote_share" here, so not sure. We could provide a more generic share notifier with these type by refactoring.
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.
My point isn't refactor, it's just move the code block to a private function in order to make this swicth block as compact as possible.
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.
moved
apps/files_sharing/lib/Notifier.php
Outdated
); | ||
} else { | ||
$notification->setParsedSubject( | ||
(string)$l->t('User %1$s shared "%3$s" with you', $params) |
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.
Missing space after the typecasting (for consistency with the rest of the code)
|
Codecov Report
@@ Coverage Diff @@
## master #30106 +/- ##
============================================
+ Coverage 62.72% 62.82% +0.09%
- Complexity 18292 18369 +77
============================================
Files 1148 1151 +3
Lines 68669 69051 +382
Branches 1234 1260 +26
============================================
+ Hits 43076 43381 +305
- Misses 25232 25301 +69
- Partials 361 369 +8
Continue to review full report at Codecov.
|
Added notification when autoaccept is disabled. It includes a private link for the accepted share. Also added notification icon. |
|
|
|
I've pushed some changes. It is already possible to accept and reject shares from the notification buttons. This is still very rough and I'm afraid we might have side effects. I'm not happy by the fact that we have a single endpoint "/shares" for both outgoing and received shares and also common code for I've added some todos above, we need to make sure this works with reshare / share initiator. It will anyway require a full retest of the sharing feature for user/group and also the "shared with me" and "shared with you" file lists, which seem to be affected by the share state somehow. The endpoint "/shares?shared_with_me=true" now has an additional arguments "state":
From here on we'll be able to adjust the "shared with you" list to also visually display pending and rejected shares. |
I don't think that It might be nice if the state can accept a list, something like |
Thanks for your comment. I wasn't sure either.
I don't want to add muultiple state values as input as it would introduce a lot more logic for not much gain as you said. |
Now struggling with the fileactions part: the "Shared with you" list already displays the pending shares now. We need to adjust the file actions menu to display "accept" and "reject" actions or others, but not the default actions. Currently, the FileActions object was designed based on its legacy: to define file actions based on mime type + permissions. Ideally it should be refactored to provide custom actions with custom filtering behavior instead of mime/permissions. This way we could have the custom handler filter out actions based on the current file row that was clicked. Whatever change we do, we need to keep it compatible with the old way to avoid breaking apps that register their actions. |
I've made a new PR to look into making file actions more flexible: #30478 |
5367bb4
to
7f12790
Compare
Pending shares can now be accepted in "shared with you", but with many bugs:
|
the favorite star is missing so the first column is not wide enough for pending shares: I wonder if we could reuse that space to display the icon as a state ? @felixheidecke |
Rebased to fix conflict in the ManagerTest. Note that 7ded301 has been added due to a bad conflict resolution (probably) since that piece wasn't there before the rebase. |
@jvillafanez seems you discarded @individual-it's commit, likely because you guys updated at the same time. @individual-it can you push it again ? |
commit was 66584e1 |
- Reusing the "oc_share.accepted" field to store share states. - Added checkbox in settings page to enable automatically accepting shares, this defaults to enabled currently. Unchecking this option will prompt users to accept or reject shares through notifications - Added pending and rejected shares in the "Shared with you" view - The "unshare from self" action now changes the state of shares to "Rejected" instead of deleting directly Introduce updateShareForRecipient methods - New method updateShareForRecipient on share manager and default share provider to update both "files_target" and "accepted" fields. - Rewired moveShare and updateShareForRecipient to use updateShareForRecipient. - Moved most of the validation code to the share provider Migrate oc_share.permissions zero to accepted field Added migration that sets oc_share.accepted to 2 (rejected) for all sub-share entries that had oc_share.permissions=0. The zero permissions is left there to avoid expensive migration and is now gracefully ignored by the current code.
Improve visual share status (icons)
Shared with you can now be sorted by share state In that order: accepted, pending, rejected and then by file name. Better error handling when switching share state Pending share support for multiple received shares Whenever multiple shares for the same node are received through different, the accept/reject endpoint now properly sets the state for all related shares. Make pending shares unclickable Exclude share owner and initiatior from notifications Hack to make share file lists reload properly Fixes issue with Firefox soft reload due to hidden field keeping its value. Deduplicate share target directly when accepting share Solves issue where the order in which the deduplication is done in the mount provider doesn't always match the accepting order Resolve private link for shared with you Sharing's notification publisher now rely on symfony event Notification is sent on share.afterCreate and discarded on share.afterDelete Share object is now passed through share creation event so no need to get it. Remove notification on auto accept
remove class .disable-click; .share-state-rejected handles the job Default cursor for folder and sharer in pending state
better xpath for finding file on Trashbin use better behat steps in tests API test to reaccept shares enable apps via APPS_TO_ENABLE in api test script UI tests to check notifications API tests to check notifications check notifications with regular expressions enable auto_accept_share between tests api tests for Discard notification if target user is not member of the group anymore test notification link redirection
Remove the notification once an action has been taken Remote shares will keep the old behaviour
run sharing notifications tests enable notifications app
Fix retarget problem after accept / decline the share Fix deduplication logic and add tests for it Fix icon url for non-root ownCloud servers Code style fixes and adjust acceptance test Remove summary when the filelist is destroyed
only source file if its availiable notifications do show users display name, fix expectations in tests
7ded301
to
10197f6
Compare
I made the same changes in a new commit, rebased and pushed again. All is good with acceptance tests. |
🎉 fantastic work, guys ! 🎉 @jvillafanez please backport to stable10 |
Backport |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description
New notification to accept shares and pending shares list
Related Issue
#19153
Motivation and Context
How Has This Been Tested?
TODO - for testcases see #30106 (comment)
Screenshots (if appropriate):
Types of changes
Checklist:
TODOs: