v2.0 threading uses cases
Here you will find a list with some typical uses cases in order to illustrate how m2f threads messages together.
Table structure
MESSAGE: id, parentId INDEX: messageId, hostId, hostMessageId
The MESSAGE table stores the tree structure of messages. For channels that are plain, like phpBB, every new post in a topic will be considered a reply to the most recent post.
The INDEX table stores the relationship between m2f messages and external messages. An external message is uniquely identified by its hostId (i.e. phpBB installation key) and hostMessageId (i.e. phpBB’s post_id)
Use Cases
phpBB post sent to m2f
- m2f.php is invoked
- send the following to m2f central server:
- post_id of the new post
- body & subject
- array of all post_id’s from the topic so far
- the host_id of this installation of phpBB
- m2f receives the post, converts to MESSAGE
- MESSAGE is indexed:
- search INDEX table for a match in the ‘hostMessageId’ column on any of the array of post_id’s, where the ‘hostId’ column also matches the host_id
- if we get a match, we get the messageId of that row, and set that as the parentId of the MESSAGE
- if there’s no match, no parentId is set
- we INDEX the message using the messageId, hostId and hostMessageId (the phpBB post_id)
m2f message sent to phpBB
- MESSAGE is received by the phpBB Export channel. It may or may not have a parentId.
- if MESSAGE has no parent, send it to phpBB as a new topic
- if it has a parent:
- search INDEX table, using the hostId of this particular phpBB installation
- Going back along the conversation history, from leaf node to root, get an array of all the INDEX records where hostId matches. Get all their hostMessageId fields, and we have an array of phpBB post id’s
- send MESSAGE to phpBB
- if message has no parents, post as new
- if message comes with an array of post_id’s, we search for the topic which contains the newest of those posts, and that becomes the topic_id for our Reply we return the post_id of the new phpBB post
- INDEX the resulting phpBB post: using the messageId, hostId and hostMessageId (the phpBB post_id)
email comes in to m2f
- m2f converts email into a MESSAGE
- scan for In-Reply-To header, and References header. If any of these are m2f-owned ids, put them in an array of possible parents
- MESSAGE is indexed:
- search MESSAGE table for most recent record where the id matches one of the array of parents
- this id becomes the parentId of our new MESSAGE
- INDEX the message using the messageId and hostMessageId (the whole Message-Id header of the email). The hostId field of the INDEX will be NULL
m2f sends email
- MESSAGE is received by the SMTP export channel. It may or may not have a parentId.
- construct the email:
- Message-Id header is set to the id of the MESSAGE (plus other m2f identification)
- if MESSAGE has a parentId, set the In-Reply-To header to the parentId (plus m2f identification)
- if MESSAGE has a parent, get an array of all the parents up the thread heirarchy to the root. Add each of these to the References header (if there are many, truncate the middle leaving a few at beginning and a few at end check RFC for this)
- index the MESSAGE







