I was just about to have a look at the option to delete messages... but there are a few questions that need answering first.

What do we mean by delete?

I assume that for the message to be removed from the database *both* the author and the recipient need to delete it?

The only way I see this working is having two additional fields showing delete status in pm_index - one for author, the other for recipient. The problem with this is that messages are not really deleted. Maybe a cron job to remove all messages where both are set to deleted?

In threaded view, does delete mean just delete one message, the whole thread or a choice?

The way I envision it would be a menu item for messages/view/%/delete which would be a confirmation form. The message with id matching the % would be checked for deletion. The rest unchecked, with an option to "check all".

Am I on the ball?

PS yes - I am avoiding looking too much at the theming side. :P

Comments

mrtoner’s picture

I assume that for the message to be removed from the database *both* the author and the recipient need to delete it?

I vote for deleting only the message from the Inbox/Sent messages of the person doing the deleting. Another normal user should not have the right to delete messages in my Inbox/Sent messages which I might be archiving.

However, a "Call back" feature could be implemented which would delete an unread message from the recipient's Inbox.

In threaded view, does delete mean just delete one message, the whole thread or a choice?

Give the user a choice: just this message or all.

naheemsays’s picture

eurghhh, this is making my head hurt!

The "proper" way to do this would be to have something per mid storing the delete status for the author and for the recipient.

When loading each message:
1. if the user loading it is the author and the mid setting is that the author has deleted it (in all the rows where the mid is stored), then do not load and move onto the next message.
2. if the user loading it is the recipient and the mid setting is that the recipient has deleted it, then move onto the next message.
3. If the user is neither and has permission to load, then only load the message if either the author or a recipient has not deleted it.

But this still leaves the issue of the lists - adding such conditionals into the privatemsg_privatemsg_list_alter would be tricky.

Ideas?

I want to get the architecture into place asap, probably leave the UI to delete for later on, but this is proving a tricky thinking exercise.

mrtoner’s picture

Hmm. I have a problem with the current schema. As the schema is right now, for each message that a user sends to a given recipient a record is stored only one time in pm_index. If User A sends a message to User B and User C, two records are stored in pm_index. Those pm_index records each refer to a single instance of a message which resides simultaneously in my Sent messages and the recipient's Inbox.

Going back to what I said in #1:

I vote for deleting only the message from the Inbox/Sent messages of the person doing the deleting. Another normal user should not have the right to delete messages in my Inbox/Sent messages which I might be archiving.

Unfortunately, with the current schema, a message cannot be deleted from User A's Sent messages without that message also being deleted from User B's and/or User C's Inbox.

In order to "properly" delete a single instance of a message, when User A sends a message that message must be indexed separately in pm_index with User A as the recipient/participant. So, for each message that a user sends, (n+1) records (where 'n' is the number of recipients) are stored in pm_index. When a message is deleted, only the pm_index record for the participant is deleted -- and the other participants in the thread retain their copy of the message.

The pros nbz lists in #4 of #302403: Author in both tables? are still relevant, and this moves us closer to a unified Inbox (no Sent messages) as well.

naheemsays’s picture

I don't see how that will work - the extra record will not contain all the participant data. I don't think we can realistically delete the data from the table.

PS with what I was discussing above, I was assuming two new columns in pm_index: author_del and recipient_del. If either is set to zero, it would signify that the corresponding user has deleted the message. (similar to how it is done in the drupal 5 version of the module.)

mrtoner’s picture

I don't see how that will work - the extra record will not contain all the participant data.

Sure it will! If User A's sent message (using my example above) is inserted into pm_index with User A as both the author and the recipient, that record has all the same information as the other records for that thread.

PS with what I was discussing above, I was assuming two new columns in pm_index: author_del and recipient_del. If either is set to zero, it would signify that the corresponding user has deleted the message. (similar to how it is done in the drupal 5 version of the module.)

I understood that. As I see it, that

  • Increases the overhead for each message saved to the db
  • Leaves data in the db instead of actually deleting it
  • Doesn't answer my objection to allowing another user to delete messages in my PM store.
litwol’s picture

the *delete* functionality should actually delete the data. later when we implement tagging we will allow people to move messages to *trash*.

naheemsays’s picture

@mrtoner - that does not keep the data about all the participants in a conversation. Once a user has deleted their "row", it is as if they have not taken par tin the conversation and there will be no way to send future replies to them.

Your approach seems to be identical to what I proposed and then found fault with in the other topic, except with an additional column.

@litwol - We probably can't delete a message from the db until after every participant no longer has it in their messages list.

mrtoner’s picture

@nbz: I see the problem. Should we keep a list ("uid, uid, uid, ...") of the participants in a pm_threads table? One row for each thread, with thread_id, participants, and subject. That would allow us to get the subject out of pm_messages, since it won't be editable in a thread, anyway.

Records in pm_messages, it is true, cannot be deleted until all related records in pm_index are deleted.

naheemsays’s picture

Would that not make pm_index redundant?

As an alternative, phpbb3, for its messages has a text column in its database with the data in it as "u_{uid}" or "g_gid" all separated by commas.

naheemsays’s picture

Actually, I think I got an idea on how to do the queries with the two columns indicating delete. Just need to get the conversations patch rewritten first as that will add the needed architecture.

mrtoner’s picture

Would that not make pm_index redundant?

To a small extent. Rather than putting that data in pm_index for each instance of a message (once for each participant), though, it's only in pm_threads once for each thread.

However, having thought about it, I see what you're trying to accomplish with the two delete columns and remove my objections in #5. #5-1 and #5-2 are probably a wash with any other solution; #5-3 is addressed by your schema.

naheemsays’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new2.82 KB

ok, here are the architecture changes for delete. This applies after #288224: Show conversation instead of just single post.

I would look this to go in and any UI for the function to be considered separately.

naheemsays’s picture

Title: Delete Button action » Delete Architecture
mrtoner’s picture

Status: Needs review » Reviewed & tested by the community

There are some code offsets, but patch applies. Database fields are created, deleted messages are hidden from the view of the user that deleted. Good to go!

litwol’s picture

Status: Reviewed & tested by the community » Needs work

This does not work as intended.

I will write out more detailed info later. but for now all i did was send message from user a to b, then reply from b to a, then reply from a to b.

Then i sent into the database and set 'author_delete' for user A to 1 for both messages.

refresh the page. _nothing changes_. no visual change after the DB change.

mrtoner’s picture

litwol, check again after making sure User 1 is not the author or recipient of a message. It's likely that what you are seeing is due to the access check for "read all private messages." A user with that permission will be able to see his own deleted messages.

I'd like to tackle that issue in my pending access control patch, if everything else in this patch is okay.

litwol’s picture

User A is uid = 1. however viewing messages through some one else's account, even with view all messages permission, should stil abide by the fact that author set his message to 'deleted', therefore should not be seen.

naheemsays’s picture

Status: Needs work » Needs review
StatusFileSize
new3.55 KB

Dumber version of the patch without the logic showing even the deleted messages to users with permission to read all messages.

Also bundled in the fix for the count of unread messages to count distinct threads.

naheemsays’s picture