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

feat(meetings): Add endpoint to get writable calendars and the defaul… #13964

Closed

Conversation

nickvergessen
Copy link
Member

…t calendar

☑️ Resolves

🛠️ API Checklist

🚧 Tasks

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not possible
  • 📘 API documentation in docs/ has been updated or is not required
  • 🔖 Capability is added or not needed

@nickvergessen nickvergessen added 3. to review enhancement feature: api 🛠️ OCS API for conversations, chats and participants feature: meetings 📅 Covering the webinary usecase incl. Lobby labels Dec 9, 2024
@nickvergessen nickvergessen added this to the 🖤 Next Major (31) milestone Dec 9, 2024
@nickvergessen nickvergessen self-assigned this Dec 9, 2024
@Antreesy
Copy link
Contributor

Antreesy commented Dec 11, 2024

Noticed that default calendar has a color 'null'. Is it also the case for you, and is it on our side?

In calendar app i see it as purple, but maybe that's a fallback

@nickvergessen
Copy link
Member Author

Noticed that default calendar has a color 'null'. Is it also the case for you, and is it on our side?

Color can be null, yes (as defined on the API). In that case you should use the primary color.

Comment on lines +157 to +173
protected function getSchedulingCalendarFromPropertiesTable(string $userId) {
$propertyPath = 'principals/users/' . $userId;
$propertyName = '{urn:ietf:params:xml:ns:caldav}schedule-default-calendar-URL';

$query = $this->db->getQueryBuilder();
$query->select('propertyvalue')
->from('properties')
->where($query->expr()->eq('userid', $query->createNamedParameter($userId)))
->andWhere($query->expr()->eq('propertypath', $query->createNamedParameter($propertyPath)))
->andWhere($query->expr()->eq('propertyname', $query->createNamedParameter($propertyName)))
->setMaxResults(1);

$result = $query->executeQuery();
$property = $result->fetchOne();
$result->closeCursor();

return $property;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should go through the DAV app to get the default calendar URI, or you can use the user config:

$uri = $this->appConfig->getUserValue($userId, 'dav', 'defaultCalendar', CalDavBackend::PERSONAL_CALENDAR_URI);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, should use that preference,
but going through the dav app is to risky as it's all private api

Copy link
Member Author

@nickvergessen nickvergessen Dec 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I toggled this:
grafik

But there is no value in oc_preferences:
grafik

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also only find delete and get for that preference, no set anywhere:
grafik

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@st3iny any ideas?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the setting can only be set by admins and is currently not documented. It acts as an override but will not be configured at all in most cases (see nextcloud/server#19852).

The official way would be to go through the CalDAV API and extract the default calendar from the principal's node.

Copy link
Member

@st3iny st3iny Jan 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exemplary code:

        $result = $this->server->getProperties(
            $principalUri,
            ['{urn:ietf:params:xml:ns:caldav}schedule-default-calendar-URL'],
        );
        $calendarPath = $result['{urn:ietf:params:xml:ns:caldav}schedule-default-calendar-URL']->getHref();

Taken from: \Sabre\CalDAV\Schedule\Plugin::scheduleLocalDelivery
This requires access to an instance of \Sabre\DAV\Server.

Copy link
Member

@st3iny st3iny Jan 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternative: Do a PROPFIND request to the CalDAV backend.

curl \
    -u admin:admin \
    --data @propfind.xml \
    -X PROPFIND \
    -H 'Content-Type: application/xml' \
    -H 'Depth: 0' \
    https://localhost/remote.php/dav/principals/users/admin

Request body (propfind.xml)

<d:propfind xmlns:d="DAV:" xmlns:cd="urn:ietf:params:xml:ns:caldav">
  <d:prop>
     <cd:schedule-default-calendar-URL />
  </d:prop>
</d:propfind>

Copy link
Member Author

@nickvergessen nickvergessen Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Options

  1. Settings up a DAV server in OCS
  2. Doing a DAV request from client side
  3. Stick with the hacky query and add the preference check before that

My POV

  1. In my opinion 1. is not possible. We would have to make sure that so many things are chained together in the right order, all apps are loaded, etc. That's not suitable.
  2. Doable/best option from API side, but requires clients to send a DAV request, but I think they all have something already for file uploads, but not sure those libs also allow caldav. Additionally it's also unfortunate that this basically means we have to do 2 requests. First one to get the calendars with write permissions, Second one to get the default target one.
  3. Basically there already and could be finished in no time

Since we are on feature freeze today, I will check with the assigned frontender if they can do it quickly with 2, otherwise we go with 3 for now.

@nickvergessen
Copy link
Member Author

Frontend is now talking CalDAV to get the calendar list and default calendar, so we will not add this.

@nickvergessen
Copy link
Member Author

Still need the POST endpoint

@nickvergessen nickvergessen reopened this Jan 7, 2025
@nickvergessen
Copy link
Member Author

Replacement at #14073

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review enhancement feature: api 🛠️ OCS API for conversations, chats and participants feature: meetings 📅 Covering the webinary usecase incl. Lobby
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants