Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Better handling of deleted messages #40

Open
ghost opened this issue Sep 11, 2014 · 6 comments
Open

Better handling of deleted messages #40

ghost opened this issue Sep 11, 2014 · 6 comments

Comments

@ghost
Copy link

ghost commented Sep 11, 2014

The docstring for the trash view says this (source):

Hint: A Cron-Job could periodicly clean up old messages, which are deleted by sender and recipient.

And the template says this (source):

Deleted Messages are removed from the trash at unregular intervals, don't rely on this feature for long-time storage.

This is not a very clean solution, in my opinion. I think it would be better to do this:

  1. Give developers an optional setting called something like MESSAGES_DELETED_MAX_AGE. If developers don't specify this setting, it could default to, say, 30 days.
  2. Modify the trash view so that it pulls in the user's deleted messages that are within the time period specified in the MESSAGES_DELETED_MAX_AGE setting.
  3. Modify the template's wording so that it says that the messages will no longer be accessible in the trash after the amount of time specified in the MESSAGES_DELETED_MAX_AGE setting.
  4. Modify the delete_deleted_messages management command so that the argument is optional instead of required. If the argument isn't given, default to the value of the MESSAGES_DELETED_MAX_AGE setting.
@arneb
Copy link
Owner

arneb commented Sep 15, 2014

You are not the first to bring up this topic, so I agree that the behaviour of the "trash" is problematic and needs to be solved.

Here is another possible way: Add the possiblity for the user to empty the trash (users should know this from their email programs). It should be tracked in the databases, if a user has permanently deleted a message from the trash. And the user will never again see the message.

Once the second user removes the message from the trash it would be deleted from the database.

@ghost
Copy link
Author

ghost commented Sep 15, 2014

You could also combine the ideas. It's what Gmail does. If you look in the trash of a Gmail account, it says:

Empty Trash now (messages that have been in Trash more than 30 days will be automatically deleted)

In other words, Gmail allows you to manually empty the trash if you want to, but if you don't, it does it automatically for messages that have been in Trash more than 30 days.

@arneb
Copy link
Owner

arneb commented Sep 15, 2014

You could also combine the ideas.

ok, that's the best idea.

@danjjl
Copy link

danjjl commented Dec 31, 2014

I am currently fixing this issue.

I am considering two implementations for marking messages as permanantly deleted:

  • Add two fields to the Message model:

     sender_permanantly_deleted = models.BooleanField(default=False)
     recipient_permanantly_deleted = models.BooleanField(default=False)
  • Set ..._deleted_at to less than today() - MESSAGES_DELETED_MAX_AGE (eg. 1 January 1970).

Which implementation should I favor?

I have already implemented the part where messages older than MESSAGES_DELETED_MAX_AGE do not appear in the trash (see https://github.com/danjjl/django-messages)

@arneb
Copy link
Owner

arneb commented Jan 12, 2015

@danjjl maybe a combination of both methods would be the best solution?
Adding the new fields allows user to permanently delete messages at their will. Additionally using the MAX_AGE approach developers can configure a "timeout" when messages should disappear from the trash ...

@danjjl
Copy link

danjjl commented Jan 12, 2015

@arneb I am not sure my last message was clear enough.
I was talking about how to mark a message as permanently deleted internally. i.e. what happens when a user presses on the permanently delete button.

But your message does answer my question. I can add two fields to the Message model.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants