Orchard IM

Topics: Customizing Orchard, Writing modules, Русский (Russian)
Sep 21, 2012 at 10:01 PM
Hello, Does anybody has success to implement IM between users? I need this feature in my future orchard app. It would be great, if somebody can suggest me the right way to implement instant messaging module. As a result I would like to have an ability to send instant messages to other users and see the list of messages in inbox. Thanks!
Sep 26, 2012 at 10:01 AM

Any ideas?

Sep 26, 2012 at 10:25 AM

Did you mean private message? You can create a new module on it. :)

Sep 26, 2012 at 10:33 AM

Yes. I'm about private messages. 

I uderstood, that I should create new module :) 

I wrote this post  hoping to get suggestions on correct implementation of such module. 

Anyway, thank you. -)

Sep 26, 2012 at 10:39 AM

As as starter, you can make use of the Orchard.Users module, which has some basic implementation for user account. 

Developer
Sep 26, 2012 at 11:14 AM

As @wooncheck said, what you want is private messaging, not IM.

I thought about it and it seems quiet complicated to implement in Orchard, but here is a link with a table schema to explain how you could design it :

http://stackoverflow.com/questions/3370647/database-design-for-email-messaging-system?answertab=votes#tab-top 

TL;DR : You need 3 content types (User, Message, Folder) and one relationship table (User_Message_Folder with columns UserId, MessageId, FolderId, IsRead and DateCreated)

Folders are typically the sames that you find in an email client : Inbox, Sent items, Deleted items, Drafts.

 

With that kind of architecture, you would be able to create a message and to affect it in the 'Sent items' folder for the sender and in the 'Inbox' folder for each recipient.

Then, you should make a PrivateMessagingService with some methods like : 

List<MessageDetails> GetMessagesByUserFolder(int userId, int folderId, bool? isRead)

--> a MessageDetails is an object that has the properties of a Message and of the relationship table (IsRead, DateCreated, ...)

void MoveMessageToUserFolder(int messageId, int userId, int folderId) 

SetMessageAsReadInUserFolder(int messageId, int userId, int folderId, bool read) --> to specify if a message is read or not

List<User> GetUsersByMessage(int messageId) --> to get the recipients of a Message

List<Folder> GetFolders() --> an further enhancement will be to have global folders and then additionnal folders by users.

 

With this, you would be able to make a 'web mail like UI' that allows to display folders, messages by folder and to set them as read.

The create message and the message details would be the Edit and Details views but it would need a specific Editor and Display shape to add recipient (autocomplete with username or user list ?) or display the recipient ('To' : comma separated list of usernames ? ).

Sep 26, 2012 at 11:49 AM

Thank you for your suggestion, agriffard!!! That is what i have expected! Right now we have implemented simple private messaging module, but without folders support and read/unread status. 

agriffard wrote:

The create message and the message details would be the Edit and Details views but it would need a specific Editor and Display shape to add recipient (autocomplete with username or user list ?) or display the recipient ('To' : comma separated list of usernames ? ).

To send message in our app, user should go to the recipients profile (by clicking on the user name in the blog post for example) and click 'Send message' link. In this case we will know the recipients userid. 

Message Folders is a good approach for us. 

Our next goal will be implementing 'Friends' module.

 

 

Developer
Sep 26, 2012 at 12:54 PM

The 'Send message to user' is a nice simple approach.

I'm asking if the Custom forms and the Rules modules would allow to make it easily.

With Custom Forms, you can add an create form of a custom content type.

With Rules, you can trigger events (like when a content type is created), to send an email for example.

Developer
Sep 26, 2012 at 12:59 PM

You should open another discussion to explain what you want in a 'Friends' module and ask for advices.

It can also be complicated if you want to make features like Friends requests, friends selector, display to friends, suggest friends, ...