Mail and Conversations (POP)
The pop submodule of com owns the in-app messaging plumbing: conversations attached to a domain entity, mail messages (inbound, outbound, notifications, comments) flowing through those conversations, attachments on each message, and the per-user follower bookkeeping that drives reply-by-mail and read/starred state. It depends on com.org for the company a conversation lives in, on com.par for the partner mail is from/to, on sys.usr for authors and followers, and on sys.xch to actually send and receive emails.
Concepts
ConversationA thread of mail messages linked to a domain entity (a sales order, a purchase order, a partner, …). Other modules call
findOrCreateConversationto attach a conversation to "their" record without owning the entity-to-conversation glue themselves.Mail MessageOne message inside a conversation. Carries from/to/cc/bcc, subject and body, the type (inbound/outbound/notification/comment), and a derived status. Outbound messages start as drafts and become "sent" when processed; inbound messages are received from the mail provider and become "read" once a follower opens them.
Mail Message TypeWhether a message is inbound (
I), outbound (O), a system notification (N), or an internal comment (C). Decides whether the message should be sent over SMTP and how its status moves.Mail Message StatusThe derived state shown in the UI — Received, Read, Draft, Sent. Each conversation message carries one of these.
Conversation FollowerA user that has opted into a conversation. Followers receive notifications and comments by mail when the message is processed.
Mail FollowerA user’s per-message read/starred bookmark on a specific mail message.
Mail AttachmentA file attached to a mail message, with optional extracted (scraped) JSON content for downstream processing.
Mail Message GroupA reference type that bundles a subject and body text-template — used as a starting point when composing notifications.
Entities
Conversation (Conversation)
A mail thread attached to a domain entity.
| Field | Description |
|---|---|
| Business key. |
| The owning finance company. |
| Optional class name of the entity the conversation is attached to. |
| Optional id of that entity. |
| Optional business code of that entity (used for searching). |
Conversation Follower (ConversationFollower)
A user that follows a conversation.
| Field | Description |
|---|---|
| Owning conversation (composite business key with |
| The follower. |
Mail Message (MailMessage)
One message in a conversation.
| Field | Description |
|---|---|
| Business key — the RFC-822 Message-ID (synthesized for system messages). |
| Inbound, outbound, notification, or comment — see Mail Message Types below. |
| Optional user that wrote the message. |
| Optional company the message belongs to. |
| Optional partner the message is from/to. |
| Sender email address. |
| Optional primary recipient. |
| Optional CC/BCC lists. |
| Message subject and body. |
| Optional group whose subject/body templates were used. |
| Timestamp the message was sent (outbound). |
| Timestamp the message was received (inbound). |
| Optional Message-ID this message replies to. |
| Optional direct parent in the thread. |
| Optional thread root. |
| Optional reference back to the domain entity the message is about. |
| The conversation the message belongs to. |
| Status flag: whether the message has been processed (sent/handled). |
| Derived status — see Mail Message Statuses below. |
A validation rule enforces that any parentMessage, rootMessage, or conversation referenced by the message belongs to the same partner and company as the message itself.
Mail Message Types (MailMessageType)
| Code | Name | Meaning |
|---|---|---|
| Inbound | Received from the mail provider. |
| Outbound | Authored in the ERP, to be sent over SMTP. |
| Notification | System-generated notification, distributed by mail to conversation followers. |
| Comment | Internal comment, distributed by mail to conversation followers. |
Mail Message Statuses (MailMessageStatus)
| Code | Name | Meaning |
|---|---|---|
| Received | Inbound message received but not yet read. |
| Read | Inbound message a follower has read. |
| Draft | Outbound message not yet sent. |
| Sent | Outbound message dispatched over SMTP. |
The status is derived: a message is Draft while not processed, Processed (and archived) once processed.
Mail Follower (MailFollower)
A user’s read/starred bookmark on a specific mail message.
| Field | Description |
|---|---|
| The message (composite business key with |
| The user. |
| Whether the user has starred the message. |
| Whether the user has read the message. |
Mail Attachment (MailAttachment)
A file attached to a mail message.
| Field | Description |
|---|---|
| Owning message (composite business key with |
| File name. |
| Path to the file on the document store. |
| Optional JSON extracted from the file by downstream scraping (operational field). |
Mail Message Group (MailMessageGroup)
A bundle of subject and body text templates used as a starting point when composing a notification.
| Field | Description |
|---|---|
| Business key (up to 8 characters). |
| Human-readable name. |
| Text template used for the subject. |
| Text template used for the body. |
Functionality
Conversation creation and reuse
MailMessageWriterService.createConversation allocates a new Conversation and links it to a domain object reference (type/key/code). findOrCreateConversation is the idempotent variant — it locates the existing conversation for an entity and returns it, or creates a new one if none exists. Other modules use this to attach a conversation to "their" record without owning the entity-to-conversation glue.
Outbound email posting
postOutboundEmail records a fresh outbound MailMessage against a conversation with the supplied To/CC/BCC, subject, and body. The message is created in Draft state; sending it over SMTP happens when the user (or a downstream job) processes the message.
Follower management
addFollower adds the current user as a follower of a conversation. The matching UI action mailMessageFollow (on MailMessageViewModel) calls into the same service. Followers receive notifications and comments by mail when those messages are processed.
Mail-message processing
The process and processUndo write actions on MailMessageViewModel flip the message between draft and processed status. MailMessageProcessor.sendOutboundEmail is the engine behind processing: it reads the conversation’s followers and decides whether the message should be dispatched over SMTP and whether it should be marked processed. The behaviour depends on the message type:
| Type | Behaviour on process |
|---|---|
| Sent over SMTP to every follower; the message is marked processed. |
| Sent over SMTP to every follower; the message is marked processed. |
| Not re-sent; the message stays as it was received. |
| Sent over SMTP to the message’s To/CC/BCC; the message is marked processed. |
The actual SMTP send is delegated to `sys.xch’s command API; this submodule only orchestrates the message-level state.
ViewModel ergonomics
MailMessageViewModel sets the author to the logged-in user on createRecord and synthesizes a fresh internetMessageId. It also derives sane defaults for sentAt / receivedAt based on the chosen mailMessageType and refuses to create inbound messages from the UI (those originate from the mail provider). On a processed message, all fields except those of an inbound message are hidden; for inbound processed messages they are read-only.
Public API
COM_POP_QueryApi
Read-side facade.
| Method | Description |
|---|---|
| Mail messages of a given type and processed flag. |
| All attachments of a message. |
| All mail attachments. |
COM_POP_CommandApi
Write-side facade.
| Method | Description |
|---|---|
| Creates a fresh conversation for a domain object reference. |
| Returns the existing conversation for an entity, or creates one. |
| Records a draft outbound mail message in a conversation. |
| Adds the current user as a follower of the conversation. |
ViewModel actions
| Action | User-visible effect |
|---|---|
| Adds the current user as a follower of the message’s conversation. |
| Processes a draft message: sends notifications/comments/outbound mail and marks the message processed. |
| Reverts a processed message to draft state. |