-
-
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
fix(calendar): Fix getting the permissions of the user #49731
base: master
Are you sure you want to change the base?
fix(calendar): Fix getting the permissions of the user #49731
Conversation
lib/public/Calendar/ICalendar.php
Outdated
*/ | ||
public function getPermissions(): int; | ||
public function getPermissions(?string $principal = null): int; |
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.
Do we want to open this box? I assume getkey, getUri, getDisplayName and getDiplayColor will have the same problem, as the values may be different for the sharer and the sharees? 🙊
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, we somewhat need it for Ability to quickly schedule a meeting spreed#6292 aka Schedule meetings inside Talk calendar#6516 otherwise we can not filter the calendars to only show the ones that the user can actually create events in.
- And if the others are affected as well, yes we somewhat need to fix them as well.
- The URI and name is already overwritten, so the knowledge for whom we get the calendars should be there?
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 get that we need to fix it. I'm just wondering if we should take a different approach. If you got the calendar objects through \OCP\Calendar\IManager::getCalendarsForPrincipal
I'd expect the permissions to already be specific to the principal passed there, and not having the need to specify the principal another time later on.
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.
You could add a new method on the IManager
that only returns writable calendars, and filter directly in this method.
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.
If you got the calendar objects through
\OCP\Calendar\IManager::getCalendarsForPrincipal
I'd expect the permissions to already be specific to the principal passed there
Also makes sense. Should we add a new method which does that, or add a new method which has the current (unexpected) behaviour, or not have the old behaviour anymore at all.
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.
You could add a new method on the IManager that only returns writable calendars, and filter directly in this method.
If getPermissions
is correct this should not be needed anymore as the OCP consumer can easily filter.
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, fixed the permissions. ✅
For the color and the name, I would do a DB query in CalendarProvider::getCalendars
against the oc_properties
table, in lack of another good abstraction (I tried OCA\DAV\DAV\CustomPropertiesBackend
but that requires a PropFind
object, which is failing to generate in OCS requests with Could not resolve Sabre\DAV\ICollection! Class can not be instantiated
).
Or does someone have better ideas that can be implemented until end of the week?
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.
If you get the calendars via the IManager, isn't that (color, displayName) already contained within the calendarInfo?
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.
Color and name need properties lookup. Let's tackle that separately when we need it.
Signed-off-by: Joas Schilling <[email protected]>
be795ab
to
4fd84e4
Compare
Checklist