server icon indicating copy to clipboard operation
server copied to clipboard

Calendar and Contacts Trashbin

Open georgehrke opened this issue 9 years ago • 58 comments

We already provide a trash bin for files, that allows users to restore deleted files. I'd like to see something similar for calendars and contacts.

This also helps users who accidentally deleted events/contacts or an entire calendar/addressbook in their client.

Todo

  • [x] Calendar and event trash bin
  • [ ] Calendar subscription trash bin
  • [ ] Address book and contact card trash bin

cc @jancborchardt @tcitworld @schiessle

georgehrke avatar Oct 07 '16 18:10 georgehrke

There are a few questions that need a prior discussion:

  • Which app shall implement the features logic?
    • dav
    • a new dav_trashbin
    • calendar respectively contacts

I'd not like to see it in the latter, because you can use CalDAV and CardDAV without the Calendar and Contacts app. Therefore the trash bin should always work, no matter whether the web gui is enabled.

  • Which app shall implement the GUI?
    • dav respectively dav_trashbin in the personal settings area
    • calendar respectively contacts

I'd actually go with calendar and contacts here. We can't do this with plain CalDAV/CardDAV. Therefore it's acceptable to having enable calendar respectively contacts before restoring imo.

I'd suggest to provide the trash bin via remote.php/dav/calendars_trashbin/ respectively remote.php/dav/addressbooks_trashbin/.

@schiessle I wasn't able to find the trash bin via remote.php/dav/. Does files_trashbin already use WebDAV for talking to the server?

georgehrke avatar Oct 07 '16 18:10 georgehrke

However it would be of no use if the calendar/contacts app aren't here since you wouldn't be able to restore deleted calendars/contacts.

Yes, but there are the following scenarios:

Dav app takes care: You delete a calendar by accident -> the calendar is moved to a trash bin by the dav app -> you enable the calendar app -> you restore the calendar

Calendar app takes care: You delete a calendar by accident -> ¯_(ツ)_/¯

georgehrke avatar Oct 07 '16 18:10 georgehrke

Totally agree with all of these. If I understand correctly, putting an item in the bin would mean moving the data from the oc_calendars table to oc_calendar_bin, while not touching oc_calendar_objects. Do the data from oc_dav_shares must remain too ?

tcitworld avatar Oct 07 '16 18:10 tcitworld

Couldn't we just create a flag, and some sort of hidden calendars/events which are not exposed, unless you propfind with a the special property? I think that would be very few lines to implement.

When you delete a calendar/event and it does not have the flag yet, we set the flag. If the flag already exists it's deleted from the system.

nickvergessen avatar Oct 10 '16 07:10 nickvergessen

That would indeed be a good solution. Instead of the flag I'd probably go for a timestamp, which is null by default. This allows us to easily delete deleted calendars/events older than n days.

georgehrke avatar Oct 10 '16 07:10 georgehrke

But there is actually one issues I'd like to discuss before implementing this:

When a calendar/addressbook (but also event/contact) is deleted, the uid should be available again. What to do about this? Replace the uid (or uri for event/contact) with a random string?

Keep this random string when replacing or tell the client to send a new uid along the request?

The dav_shares table uses the calendar id and not the calendar uri, we don't need to change anything there. The behavior should be the same as in the files app. Restoring a calendar/addressbook also restores all the shares.

georgehrke avatar Oct 10 '16 12:10 georgehrke

Reminder for myself: Do not return deleted calendars on allprop request

georgehrke avatar Oct 10 '16 12:10 georgehrke

When a calendar/addressbook (but also event/contact) is deleted, the uid should be available again. What to do about this? Replace the uid (or uri for event/contact) with a random string?

As long as there are no duplicates on restoring, fine by me.

nickvergessen avatar Oct 10 '16 14:10 nickvergessen

Yes, the db won't allow duplicate URIs. https://github.com/nextcloud/server/blob/master/apps/dav/appinfo/database.xml#L375

georgehrke avatar Oct 10 '16 14:10 georgehrke

Regarding where to store it – definitely directly in the Calendar respectively the Contacts app. cc @Henni @irgendwie

jancborchardt avatar Oct 11 '16 07:10 jancborchardt

Do you mean store or restore?

Please excuse my brevity and typos. Sent from my mobile

On Oct 11, 2016, at 9:36 AM, Jan-Christoph Borchardt [email protected] wrote:

Regarding where to store it – definitely directly in the Calendar respectively the Contacts app. cc @Henni @irgendwie

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub, or mute the thread.

georgehrke avatar Oct 11 '16 07:10 georgehrke

A bit late to the discussion, but I agree with the conclusion by @georgehrke. Think this is a good way forward.

schiessle avatar Oct 24 '16 09:10 schiessle

@georgehrke it was a reply to your previous question:

Which app shall implement the features logic?

And I think it should be the respective app. Definitely not a new calendar_trashbin app or something like that which needs to be separately enabled.

jancborchardt avatar Oct 25 '16 11:10 jancborchardt

Please see https://github.com/nextcloud/server/issues/1662#issuecomment-252332641 on why I think this is a really bad idea. You can use CalDAV and CardDAV without enabling the respective apps.

georgehrke avatar Oct 25 '16 11:10 georgehrke

@jancborchardt this would mean that the calendar app has to be installed to offer a trashbin to all other clients. I'd prefer to implement only the gui inside the respective apps (contacts & calendar) and implement the backend (functionality) inside a different app, maybe extend dav_trashbin or even create new apps (which are enabled by default).

Henni avatar Oct 25 '16 11:10 Henni

I would really prefer to just put it in the dav app. This feature requires a Plugin for Sabre/Dav and at the moment there is no way for other apps to register sabre/Dav plugins. All the other things like comments and tags are also in the dav app.

georgehrke avatar Oct 25 '16 11:10 georgehrke

Ok, putting it in the dav app seems to make most sense then. :)

jancborchardt avatar Oct 25 '16 12:10 jancborchardt

Can this be done for Tasks in the Tasks app too? Since that also uses Dav...

spoorun avatar Dec 22 '16 05:12 spoorun

@olantrust should be possible. cc @raimund-schluessler

nickvergessen avatar Jan 05 '17 10:01 nickvergessen

I created an issue: https://github.com/nextcloud/tasks/issues/29

raimund-schluessler avatar Jan 05 '17 10:01 raimund-schluessler

Hi, just came over this issue. Is there any progress?

I think it would be fine to separate this issue in at least two or three issues. The first step may be just having a trashbin for events. Second a trashbin for contacts (I do not know how much differeces there are compared to events). Third it seemst to me a bit more complicated having a trashbin for a whole calendar. Indeed I do not know whether this is realy necessary although it is nice to have. It is no common mistake that someone deletes accidently whole calendar.

Further for the event trashbin it would be useful to have it as extra calendar. That means you could view your trashbin calendar as every other calender (also sync it if you like). Deleting an event simply means to move the event from the origin calendar to the trashbin calender. Restore is moving back. Maybe it is necessary to remember the origin calender for automatically moving back. For me it would be enough to see the event and have the ability to move it back manually.

cornzy avatar Jan 07 '18 21:01 cornzy

Are we have any SQL command can recover calendar delete events??? I have a big trouble for this...lol

lailai487 avatar Jan 27 '18 13:01 lailai487

No, the calendar / contacts trash bin wasn’t implemented yet. I’m afraid gone is gone.

georgehrke avatar Jan 27 '18 13:01 georgehrke

OMG..... Thanks your answer. Activity only log the event title? No any startdate - enddate? Maybe my boss will kill me...

lailai487 avatar Jan 27 '18 13:01 lailai487

Activity only log the event title? No any startdate - enddate?

Only the title, yes https://github.com/nextcloud/server/blob/ba3c608a00f3834f743de5a0cd82ddae3825d458/apps/dav/lib/CalDAV/Activity/Backend.php#L477

georgehrke avatar Jan 27 '18 14:01 georgehrke

I think if somebody takes a look at this she*he should think about logging the change to the activity app nextcloud/server#3549.

tacruc avatar Feb 03 '18 05:02 tacruc

Folks, let's be civil here. Yes, a way to recover deleted Contacts & Calendars would be great. 2 options:

  1. Can you help? Great! Dive into the code, communicate with the other developers, and let's make this real.
  2. OR can you not help and just want to comment here: Do not. It's notifying everyone subscribed to this issue and wastes their time. And if your comment is negative, it will make people even less likely to implement what you want to have.

jancborchardt avatar Feb 26 '18 10:02 jancborchardt

@georgehrke Nothing for 14, right? Move to 15 or backlog?

MorrisJobke avatar Jun 25 '18 17:06 MorrisJobke

Backlog for now

georgehrke avatar Jun 28 '18 08:06 georgehrke

I just accidentally deleted my contact list and I now lost all my contacts on both my phone and my computer. How is this even possible!?

dokterbob avatar Jan 05 '19 14:01 dokterbob