For my next addition to my site, I have decided to do something different. I have decided to cross private messaging with instant messaging. Basically, once a "conversation" has been started (i.e. the initial PM has been sent), all replies will be added to the same PM. This will make it much more friendly for my users as well as will reduce the clutter in the database (in our current PM system, every message, reply or toherwise, gets a row in the database). A "conversation" can happen only between two people, so there's no need to worry about multiple recipients.
Now, for the trick. Each user should also have a sent box and a trash. When a user iniates a conversation, it ends up in his "sent" box along with all the replies that take place after. If a user replies to a conversation he did not initiate, it does not end up in "sent". THe trash is just a place where deleted messages go till they're deleted permanently.
Okay, let me demonstrate with an example: John Doe sends Jane Doeth a message. It goes into John's "sent" box and Jane's "inbox". Jane replies. Jane can immediately see her reply in her own inbox, and John sees Jane's message as well as his own in his inbox. John then replies and sees his message immediately in his inbox, and it goes into Jane's inbox. By the time these three events happenned, John inbox, John's sent, and Jane's inbox look like this:
Code: Select all
(oldest messages on the bottom)
...etc
John:
Also not bad. What'd you think of Edmonton winning over Anaheim?
Jane:
Not too bad, yourself?
John:
Hey. How are you?Now, I had a couple of ideas on implimenting that, but hit a roadblock each time. My initial idea was to have each conversation as a record in the database, and use that record for both people in the conversation. I hesitate to use words like "sender" and "recipient" because each person is, in a sense, both a sender and recipient. So my idea was this: set up a table with two user feilds and a message field that would be updated once replies are sent. In that sense, there is only one row for each active conversation, reducing the clutter in the database:
Code: Select all
User1 User2 Message Trash Inbox Sent
==================================================================================
John Jane John: 0 1 1
Also not bad. What'd you
think of Edmonton
winning over Anaheim?
Jane:
Not too bad, yourself?
John:
Hey. How are you?Let me know if tat was clear...it's really kind of difficualt to explain, but it's a simple intuitive idea once it's implimented. I'm looking for the most smart and efficient way of doing this. Let me know if I just won the "vaguest explanation of the year" award.
Thanks!