PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, July 12, 2022

[FIXED] How to delete messages properly?

 July 12, 2022     android, message, mongodb     No comments   

Issue

I'm a beginner in android so please do excuse me if my question seem to be foolish.Basically I've developed an one-one messaging app using socket.io and mongodb and it's working fine . It's saving a unique room key for two users in db which is accessed by them by their email id when they login to my app .

My message storing format:

{
"_id" : ObjectId("5abcf523f388e02978bf7780"),
"_mid" : "roman-reigns+john-cena",
"from" : "roman.reigns",
"to" : "john.cena",
"msg_time" : "29 Mar 2018(07-41-29)",
"msg" : "hy"

}

These things are working without any problem. I've designed the single message delete as unsend so that it would remove the sender's message and this idea seems to be fine. But now what I'm asking is how can I give total delete option to the users . I meant in my case these chat conversation will be shown in both the user's phone so when one user will try to delete all messages what would happen if I'll delete all the messages from the db at that point then the message list will also be deleted from other user and it won't be user friendly.So how can I design all delete message format so that it won't be deleted from the other person's list but be deleted from the current deleter's phone.

Please do suggest any ideas so that my problem would be solved.


Solution

You can use one more params as flag where

deleteMsg flag where 4 values can put

0 for active 1 for sender deleted 2 for receiver deleted 3 for both

If it's complex then

keep two flag

senderDeleted = 0 active 1 deleted receiverDeleted = 0 active 1 deleted



Answered By - Sameer Jani
Answer Checked By - Pedro (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing