Skip to content

fix(calendar): explain when an imported event already exists - #14016

Open
carlospintojunior wants to merge 2 commits into
nextcloud:mainfrom
carlospintojunior:fix/calendar-import-duplicate-error
Open

carlospintojunior wants to merge 2 commits into
nextcloud:mainfrom
carlospintojunior:fix/calendar-import-duplicate-error

Conversation

@carlospintojunior

Copy link
Copy Markdown

Depends on #14015. This branch is stacked on it, so until #14015 is merged the diff also shows its commit. Only the last commit (fix(calendar): explain when an imported event already exists) belongs to this PR.

Summary

Follow-up to #14015. Importing an .ics attachment whose event is already in the chosen calendar fails with the generic "Could not create event" toast, which gives the user no clue what went wrong.

The most common way to get there: accept an invitation in Mail (the event is written to the calendar), then click Import into calendar on the same invite.ics. The server rejects the duplicate UID, and the user is left wondering why.

Changes

  • DAVService.getCalendarObjects(data) returns the { component, uid } pairs of a file (one entry per UID, so recurrence exceptions are not counted twice).
  • DAVService.calendarContainsObject(url, object) runs a CalDAV calendar-query (REPORT, prop-filter UID / text-match) on the target calendar. The UID is XML-escaped.
  • MessageAttachment.importCalendar() now receives the calendar (not only its URL). When the import fails, it checks whether the attachment's objects already exist in that calendar and shows "This event is already in the calendar {calendar}". Otherwise, or if that check fails as well, it falls back to the existing generic message.
  • The server's error text is deliberately not parsed: it is neither translated nor a stable API.
  • Tests: service (DAVService.spec.js) and a new component spec (MessageAttachment.vue.spec.js) covering success, duplicate, other failure and failing check.

How to reproduce (before)

  1. Receive an invitation with invite.ics attached and accept it in Mail.
  2. Import into calendar → Personal.
  3. "Could not create event".

After: "This event is already in the calendar Personal".

Checklist

  • Unit tests added; they fail without the fix
  • eslint clean on changed files
  • Commit signed off (DCO)

🤖 Generated with Claude Code

The supported component set of each calendar was hard-coded to VEVENT,
so "Import into calendar" also offered task-only calendars such as the
default "Tasks" calendar. Importing an invitation there always failed
with the generic "Could not create event" error.

Evaluate supported-calendar-component-set, treating a missing property
as "all components" as defined by RFC 4791 section 5.2.3, and only offer
calendars that accept every component type in the attachment.

Converting an event into a task on import is intentionally not done: it
would be a new feature, not a fix. Surfacing the actual reason of a
failed import is handled separately.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: carlos <carlos@vulcanum.com.br>
Importing an attachment whose event is already in the chosen calendar,
typically because the invitation was accepted from Mail, is rejected by
the server for its duplicate UID, but the user only saw the generic
"Could not create event" error.

After a failed import, look the attachment's UIDs up in the target
calendar and say so if they are already there. The server's error text
is intentionally not parsed: it is neither translated nor a stable API.
Updating the existing event instead of failing is left out, as it
needs a decision on how to handle SEQUENCE and local modifications.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: carlos <carlos@vulcanum.com.br>
@carlospintojunior
carlospintojunior force-pushed the fix/calendar-import-duplicate-error branch from 3263ad5 to c2f6d3c Compare November 2, 2026 16:33

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant