-
-
Notifications
You must be signed in to change notification settings - Fork 4.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
Add a method to get all users with access to a file in OCP #38946
base: master
Are you sure you want to change the base?
Conversation
*/ | ||
public function getNodesByUserForFileId(int $fileId): array { | ||
$mounts = $this->getMountsForFileId($id); | ||
$rootFolder = Server::get(IRootFolder::class); |
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.
- Can this be added to the DI or is there a problem with that?
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 might make more sense to move this method to the RootFolder
instead
3ba5f1d
to
287a5a8
Compare
This already takes into account groupfolder ACLs, because Also, the check That said, in the usecase of activity, which is the only one I found so far, we do not need to merge, we only want to get one path for each file. So I’m tempted to change the method to actually return only one path for each user who has access, as a string. This will make calling code a lot clearer. |
So in the end I splitted between I would like to use But for comments and systemtags it works nicely with groupfolders now, even with ACLs. Let’s hope I did not break something else. |
It’s
I missed it because I was searching for 'remotes' , but in ShareHelper::getPathsForAccessList remote is turned into remotes actually.
(Thanks Robin for the pointer) |
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.
For the lib/public changes
80e469c
to
a95769a
Compare
Rebased on master and fixed psalm errors |
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 good overall but I would like to ensure this is somewhat performant
} | ||
|
||
$userFolder = $rootFolder->getUserFolder($uid); | ||
$result[$uid] = array_merge($result[$uid], $userFolder->getById($fileId)); |
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 feel that there should be a more efficient way to do this here since we already know the mount.
Perhaps extracting some of the logic from RootFolder::getByIdInPath
to create a RootFolder::getByIdInMounts
or similar.
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.
See #40482 (comment) for some alternate discussion around the same problem
It seems that IUserMountCache#getMountsForFileId() does not include shares because they are not listed in oc_mounts. For shares we would need something like Something like this might work, but hopefully there's a less hacky way:
|
Shares should be listen in |
Aha! That explains a lot. I also used the wrong array concatenation method (:see_no_evil: ) so, groupfolders are afterall taken care of by this method, so: sorry for the noise, all good. |
Sad times. |
@marcelklehr if womeone wanna take over, or OP wanna work again on it, they can still re-open :) |
Reopening because we need to figure this out at some point, it’s causing trouble for groupfolders. The question is whether we can do that without making the experience worse in other places. |
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
…erForFileId Optimises further and avoid duplicate code for all activity listeners Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
a95769a
to
c1c40ff
Compare
Rebased |
Since there is no other method than this currently, and we already use it in some apps, I vote to get this in, even if it's not super performant. |
Summary
In a lot of places we need the list of users having access to a file, this is especially often the case in activity providers in applications, to notify all users of an event.
Currently the implementation is done differently each time, this is an attempt to bring a method in OCP that allows to get the list of users having access to a file and under which path.
For comments for example, this fixes showing the activity event to users having access to the file through a groupfolder.
TODO
Checklist