Event Deletion and the Trash and Deleted calendars
Deleting events can be more complicated than we might expect. There are a number of cases to consider. The intent is to provide similar functions to those we find elsewhere, that is, a Trash which allows us to retrieve deleted objects if we change our mind.
Deleting non-recurring events we own.
These are easy. We move the event into the trash calendar. Note that this already introduces a complication we have to deal with elsewhere. That is, we may have more than one event with the same uid in the Trash. We need some way to reference them, that way has to be the name. We can change the name of an event but we shoud probably not change the uid. How do we get he same uid? A user imports an event, trashes it then reimports it the trashes it again.
Deleting recurring events we own.
When we delet an instance we really want to add that instance to the exdate list, or remove it from the rdate list if that's how it got there. That way, when we export the event (via ics or CalDAV) it will appear correctly in other calendars. However, we would also like to be able to preserve that event in the trash. The options we have:
- Override the event and mark it as deleted and put the override in the trash.
- Really delete it.
We don't want to really delete it, at least not until the trash is emptied so we should go with overriding it. On export it's important we note the deletion and adjust the master appropriately.
Deleting events we don't own but to which we have delete access.
Not sure. If we have the access we can certainly delete it. However, we should we cannot really put it in the trash as it stands because ownership is wrong. The options seem to be
- Really delete perhaps after notifying the user we can not put it in the Trash
- Make a copy we own put that in the trash and really delete the event
- Probably the same thing - just change owner and move it.
Deleting events we don't own and to which we do not have delete access.
This is an important action - for example, a user may subscribe to a "Films" calendar and then delete those they are not interested in. In that way, as new events appear in the calendar they will automatically appear in the users calendar and can be deleted if unwanted.
We achieve this by having a special "deleted" calendar. This calendar is searched along with the regular events and events in this calendar are effectively used as a mask to hide unwanted entries. Deleting an entry in the deleted calendar has the effect of making the masked event reappear.
Emptying the Trash
This is not just a matter of deleting the events. If the event is a simple non-recurring event it is easy, just delete it.
If it's an override then we need to adjust the master event appropriately and delete the override and instance.
Purging the Deleted calendar
We don't want to empty it. All sorts of events will reappear. However, we can purge it by removing all entries which refer to deleted events.
A thought - the presence of an entry in a deleted calendar may prevent, through database constraints, the deletion of an event. We might have to go ahead and delete annotations in deleted calendars.
