Backgroun: I’m trying to build a private messaging system in Mysql with conv view.
I have a msg_received tbl which looks like this
id from_member_id to_member_id message_id
1 123 456 101
2 456 123 102
3 123 456 103
4 456 123 103
So when userA (id: 123) views his conv history; he sees the 2 messages he has sent to userB (id:456) and and 2 messages he has received from userB (id: 456). So he sees a total of 4 messages. Same for userB; he sees a total of 4 messages.
The problem is that I would like to allow userA to delete one of those messages. Lets say that he wants to delete msg_id 103. So now userA only sees 3 messages.
The problem is that when userB tries to view the conv history; he also sees only 3 messages instead of the 4 that he should. This is because he hasn’t deleted any messages and expects to see the full history.
Can you guys provide any tips?
Add 2 flags:
deleted_by_senderanddeleted_by_recipient.When only one user “deleted” – set up approproate flag. When both flags = 1 – delete the record physically.
Also – now you’ll need to add
AND deleted_by_recipient = 0condition to yourWHERE