[Bug]: [Bug]: Automatically created iMIP invitations (Mail background job) ignore "Default calendar for incoming invitations" and always go to `personal`
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 36.9k
- Forks
- 5.2k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 713
Description
⚠️ This issue respects the following points: ⚠️
- This is a bug, not a question or a configuration/webserver/proxy issue.
- This issue is not already reported on Github OR Nextcloud Community Forum (I've searched it).
- Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
- I agree to follow Nextcloud's Code of Conduct.
Bug description
Calendar invitations that Nextcloud Mail processes automatically in the background ("Automatically create tentative appointments in calendar", Mail account setting) are always written to the calendar with URI personal, ignoring the user's "Default calendar for incoming invitations" configured in the Calendar app.
Root cause (from reading the code):
- The Calendar app stores that setting as the DAV property
{urn:ietf:params:xml:ns:caldav}schedule-default-calendar-URLon the user principal, inoc_properties, viaCustomPropertiesBackend. - Mail's
IMipMessageJob→IMipService::process()→OCP\Calendar\IManager::handleIMip()→CalendarImpl::handleIMipMessage(), which emitsscheduleon anInvitationResponseServer. InvitationResponseServerdoes not load\Sabre\DAV\PropertyStorage\Plugin/CustomPropertiesBackend, so the stored property is never read there. The only handler forschedule-default-calendar-URLin that server isOCA\DAV\CalDAV\Schedule\Plugin::propFindDefaultCalendarUrl(), which consultsIConfig::getUserValue($uid, 'dav', 'defaultCalendar', 'personal')and falls back topersonal, then to the first valid calendar by sort order.Manager::handleIMip()does callgetPrimaryCalendar()(which readsoc_properties) to pick a$calendar, butCalendarImpl::handleIMipMessage()only uses it for the principal; the actual target calendar is re-resolved inside Sabre'sscheduleLocalDelivery()viaschedule-default-calendar-URL.
Net effect: the UI setting is honored by the main DAV server (Calendar app, CalDAV clients, manual Accept in Mail) but not by the background iMIP path. Nothing is logged; oc_mail_messages.imip_processed = 1, imip_error = 0, and the object is created in calendars/<user>/personal/.
Setting occ user:setting <user> dav defaultCalendar <uri> works around it, but nothing keeps that preference in sync with the property the UI writes.
Related, already fixed for the manual Accept flow in Mail: nextcloud/mail#10983 / nextcloud/mail#11035.
Steps to reproduce
- User has at least two calendars, one of them with URI
personal, plus another one (e.g.work). - In the Calendar app → Settings, set "Default calendar for incoming invitations" to
work. Verify the row exists inoc_properties(propertyname = '{urn:ietf:params:xml:ns:caldav}schedule-default-calendar-URL',propertyvalue = 'calendars/<user>/work/'). - Make sure
occ user:setting <user> davshows nodefaultCalendarentry. - In Mail → Account settings → Calendar settings, enable "Automatically create tentative appointments in calendar".
- From an external system (Google Calendar, Outlook, another Nextcloud), send a brand-new invitation (METHOD:REQUEST, new UID) to the mail account's address.
- Wait for the
OCA\Mail\BackgroundJob\IMipMessageJobto run (or run it viaocc background-job:execute). - Check
oc_calendarobjectsjoined withoc_calendarsfor the invite's UID.
Expected behavior
The tentative event is created in the calendar selected as "Default calendar for incoming invitations" (work).
Actual: the event is created in personal. No warning or error is logged; imip_processed = 1, imip_error = 0.
Nextcloud Server version
33
Operating system
None
PHP engine version
None
Web server
None
Database engine version
None
Is this bug present after an update or on a fresh install?
None
Are you using the Nextcloud Server Encryption module?
None
What user-backends are you using?
- Default user-backend (database)
- LDAP/ Active Directory
- SSO - SAML
- Other
Configuration report
List of activated Apps
Nextcloud Signing status
Nextcloud Logs
Additional info
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Trace OCA\Mail\BackgroundJob\IMipMessageJob through IMipService::process(), OCP\Calendar\IManager::handleIMip(), and CalendarImpl::handleIMipMessage(). Compare InvitationResponseServer with OCA\DAV\CalDAV\Schedule\Plugin::propFindDefaultCalendarUrl() and the CustomPropertiesBackend path. Done means background iMIP invitations use the Calendar app's configured default calendar instead of always creating objects in personal.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100