Skip to content

feat: add event reference provider and widget#8048

Open
mejo- wants to merge 2 commits intomainfrom
feat/event_reference_provider
Open

feat: add event reference provider and widget#8048
mejo- wants to merge 2 commits intomainfrom
feat/event_reference_provider

Conversation

@mejo-
Copy link
Member

@mejo- mejo- commented Mar 8, 2026

Fixes: #7104

Screenshot

image

@mejo- mejo- requested a review from hamza221 March 8, 2026 20:38
@mejo- mejo- self-assigned this Mar 8, 2026
@mejo- mejo- added 2. developing Work in progress enhancement New feature request labels Mar 8, 2026
@codecov
Copy link

codecov bot commented Mar 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@mejo- mejo- force-pushed the feat/event_reference_provider branch 3 times, most recently from 7856804 to ae2ecc3 Compare March 8, 2026 20:46
@mejo- mejo- changed the title feat: add event reference provider and widget for feat: add event reference provider and widget Mar 8, 2026
private readonly IL10N $l10n,
private readonly IURLGenerator $urlGenerator,
private readonly IManager $calendarManager,
private CalDavBackend $calDavBackend,
Copy link
Member

Choose a reason for hiding this comment

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

This should be made backend agnostic, and use OCP\ICalendar\IManager::getCalendarsForPrincipal in the getCalendar method, and OCP\Calendar\ICalendar\search in the getEventData method.

Copy link
Member Author

Choose a reason for hiding this comment

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

Can you help me to use ICalendar::search() for finding the event? It seems like it doesn't allow to filter by event URI (e.g. 45C2F160-BA74-4910-B302-79356C24A458.ics). So my best bet would be to search for all events in the calendar and then iterate through them to get the one with the matching URI:

$event = null;
foreach ($calendar->search('') as $result) {
	if (($result['uri'] ?? null) === $eventFile) {
		$event = $result;
		break;
	}
}

This works but doesn't seem a good idea performance-wise. Or is it fine to do it that way?

Copy link
Member

@tcitworld tcitworld Mar 19, 2026

Choose a reason for hiding this comment

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

I mistook the object uri and the object uid, sorry about that.

You can call search('', [], ['uid' => $uid]);, but the object uri is not always uid.ics, so this won't work.

I think we could add a modification in the calendar backend to allow to also do search by object uri. I don't know of any implementation using ICalendar::search (or interfaces that extend it) at the moment, so it shouldn't be a problem.
https://github.com/nextcloud/server/blob/7cdbb38d526edc2c32240fffb64b035d5dc0cb35/apps/dav/lib/CalDAV/CalDavBackend.php#L2061-L2063

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea, I did this now: nextcloud/server#59142

Tested with this PR (adjusted the search() parameters) and works well.

Copy link
Contributor

@GVodyanov GVodyanov left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution!

Please use our CSS variables instead of custom values for padding/margin/gap/etc.

You can check them out here https://docs.nextcloud.com/server/latest/developer_manual/html_css_design/css.html

Fixes: #7104

Signed-off-by: Jonas <jonas@freesources.org>
@mejo-
Copy link
Member Author

mejo- commented Mar 19, 2026

I realized another problem: calendar event URLs (e.g. https://nextcloud.local/index.php/apps/calendar/dayGridMonth/now/edit/popover/L3JlbW90ZS5waHAvZGF2L2NhbGVuZGFycy9qYW5lL3BlcnNvbmFsLzQ1QzJGMTYwLUJBNzQtNDkxMC1CMzAyLTc5MzU2QzI0QTQ1OC5pY3M=/1772787600) seem to "expire" in some way. A few hours after I copied them into a document, the preview still renders correctly, but opening the URL just opens the calendar in question with a modal "Event does not exist".

Is this a bug, or are these URLs meant to be ephemeral? Is there something like a persistent URL to an event yet at all?

@mejo- mejo- requested review from GVodyanov and tcitworld March 19, 2026 17:32
Signed-off-by: Jonas <jonas@freesources.org>
@mejo- mejo- force-pushed the feat/event_reference_provider branch from ae2ecc3 to fc255c2 Compare March 19, 2026 17:50
@tcitworld
Copy link
Member

tcitworld commented Mar 19, 2026

Is this a bug, or are these URLs meant to be ephemeral? Is there something like a persistent URL to an event yet at all?

It might be related to the event occurrence added at the end (/1772787600). Did you try without it?

@mejo-
Copy link
Member Author

mejo- commented Mar 21, 2026

It might be related to the event occurrence added at the end (/1772787600). Did you try without it?

There's no route for URLs without the event occurrence part at the end, so unfortunately this leads to "Page not found" 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2. developing Work in progress enhancement New feature request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reference provider for appointments

3 participants