Internal Messaging Architecture
The internal messaging system is not a replacement for the email. The system in fact banks on the users' experience and use of the email and is powered by it. The internal messaging system is an internal mailbox that complements the users' email activities. It is a good space where all messages exchanged between users and notifications can be sorted and easily archived without mixing them with other mails that the user gets. These messages can be used as archives for all the correspondence that a user gets.
User Stories : #188, #189, #190, #191, #192, #195, #196, #197, #198, #199, #200, #201, #202, #203, #204, #205, #206, #207, #208
Acceptance tests : Internal Messaging
Internal Messaging Objects
Message Catalog
The message catalog would catalog only message objects. This should speed up searching and sorting messages.
The indexes for the catalog are is follows.
- id
- path
- from
- to
- subject
- date_trash
- date_message
- box
- has_attachment
- starred
- read
- label
The metadata for the catalog are as follows
- id
- path
- from
- to
- subject
- date_trash
- date_message
- box
- has_attachment
- starred
- read
- label
Message Tool
This should create an unique object at the portal root that has common methods, that the message templates and scripts use. It should also run schedular scripts that auto delete trashed object. Some of the methods that the message tool defines are as follows.
Methods
- trashMessages(self) - Run every day by a schedular script. Deletes all messages in the portal that are trashed 2 weeks ago
- getMembersForGroup(self, group_id) - returns all the members of the group
- getMessageFolderForMember(self, member_id = None) - returns members message folder. If no member_id is passed it returns the authorized members message folder
- searchUserMessages(self, **args) - returns a list of messages for the authorised user(use ExtendedPathIndex?). **args may accept the following parameters to, from, box(required), label, subject, starred, read, date(eg 7 days ago) and has_attachment.
- createMemberMessageFolder(self) - method called when member registers for the very first time. This method creates a folder called messages in the user's home directory.
- sendMessage(self, message_obj) calls create message method on members messages directory.
Message Container
The message container is created once the portal member registers into the portal for the first time. This also stores all the configurations for a specific member. The attributes stored on the message container are as follows.
- labels - labels that the member has created
- trash_days - days that the message remains in the folder before deletion
- notify - (True/False) when true recieves an email notification of the message
The message container has the following methods
- addLabel(self, label_name) Adds to labels when label_name is not in the list of labels
- deleteLabel(self, label_name) Deletes from list of labels and removes label name from all messages.
- getLabels(self) - returns the labels defined by the user
- deleteMessages(self, message_ids=[]) - delete messages
- createMessage(self, **args) Creates a message object on the folder
The following methods must not be defined as they are similiar in nature. One may override the getattr method and achive the same. Internally getattr must be able to handle the following method definitions :-
- trashMessages(self, message_ids=[]) - trash method called on messages
- markMessageLabels(self, message_ids=[], label=[]) - markLabels method called on messages
- removeMessageLabels(self, message_ids=[], label=[]) - removeLabels method called on messages
- markMessagesRead(self, message_ids=[]) - markRead method called on messages
- markMessagesStarred(self, message_ids=[]) - markStarred method called on messages
- removeMessagesStarred(self, message_ids=[]) - removeStarred method called on messages
- trashMessages(self, message_ids=[]) - trash method called on messages
- archiveMessages(self, message_ids=[]) - archive method called on messages
- inboxMessages(self, message_ids=[]) - inbox method called on messages
The message container has the following templates
- message_inbox.pt or message_listing.pt
- message_sent - may reuse message_inbox.pt based on request
- message_archive - may reuse message_inbox.pt based on request
- message_draft - may reuse message_inbox.pt based on request
- message_trash - may reuse message_inbox.pt based on request
- message_compose.pt
- message_forward - may reuse message_compose.pt based on request
- message_replay - may reuse message_compose.pt based on request
Message
The message object stores all the relavent data of an internal message.
- id - unique id of the message
- from - Member/Object(UID) who has sent the message
- to - All the members/groups that the message was sent to
- cc - All the members/groups that has been sent a carbon copy
- bcc - All the member/groups that has been sent a blank carbon copy
- subject - Subject of the message
- body - Rich text body of the message
- attachment - message attachment
- date_trash - date the message was trashed
- date_message - date the message was sent/saved
- box - The message may be in one of the following boxes [Inbox/Sent/Draft/Trash/Archive].
- has_attachment - (True/False) Returns true if the message has an attachment.
- starred - (True/False) The message may be marked as important
- read - (True/Flase) The message may be marked as read. It is also marked as read when the user opens the message
- label - (User Specific) The message may be marked by zero or more labels defined by the user
The message object has the following methods
- genNotificationFromMessage(self) - Returns the mail body of the message that can be used to send external mails. It must also attach the attachments of the message and an URL that on clicking would take the user to the message.
- messageDict(self) - return a dictionary of all the attributes in the message
- getLabel(self) - returns the labels of the message
- isRead(self) - returns true if the message is read
- isStarred(self) - returns true if the message is starred
- hasAttachment - returns true if the message has an attachment
- markLabels(self, label=[]) - appends labels to list of message labels
- removeLabels(self, label=[]) - removes labels from message labels
- markRead(self) - attribute read is set to True
- markStarred(self) - attribute starred is set to True
- removeStarred(self) - attribute starred is set to False
- trash(self) - date_trash updated. box set to trash
- archive(self) - box set to archive
- inbox(self) - box set to inbox
- draft(self) - saves message as draft
The message object has the following templates
- message_view - Shows the open message
- message_notification - returns an email notification for the message
Other Methods
The login form of the portal must be overridden to accept a get request. The get request may contain an attribute "objredirect" that stores the uid of a portal object. If the members has already logged in, the login form must redirect the user to the object. If the member has not logged into the portal he must fill in his username and password, on logging in he is redirected to the object.
Portlets
Message boxes portal_message_boxes.pt
- Displays all the member boxes
- Displays the number of read/unread/new messages
Message labels portal_labels.pt
- Displays all the labels for the user
- On clicking takes the user message_search_results.pt with the label search results
- Displays an "edit labels" link
Actions for Message Container Views
Manage Labels
Manages has the following templates and scripts
- message_labels.cpt
- message_manage_labels.cpy
Search Options
Search Options has the following templates and scripts
- message_search_form.pt
- message_search_results.pt
The following ajax implementations are required
- Adding Label from drop down box
- Marking Label to messages/message
- Removing Label
- Starring mails
- Marking mails as read
- Filling "to, cc, bcc" fields
- "to, cc, bcc" fields to remember previous input values
- auto saving for drafts
