Chatter storage: messages and followers
The mail addon (erp-addon-mail) stores the messages and followers of any record. This page
covers the first parts of adding a chatter to a model: the storage, the follower methods and posting
a message, and who can read one. Write access to messages, inbox and email notifications and field tracking
come with later slices of the mail addon; this page grows with them. How a client loads a
thread is under Load a thread into the client. How records and field values reach the client store (payloads, sync classes, producer
obligations) is described in Store wire.
What the addon ships:
| Model | What it holds |
|---|---|
mail.message | One row per message. model and res_id point at the record (no foreign key). Explicit recipients are in mail_message_res_partner_rel, everyone the message reached in mail_message_notified_rel. |
mail.message.subtype | Message categories. Four default records: mail.mt_comment (Messages), mail.mt_note (Notes, internal), mail.mt_activities (Activities, internal) and mail.mt_important_notification (internal). |
mail.followers | One row per partner following a record, unique on (res_model, res_id, partner_id), with the subtypes the partner receives in mail_followers_mail_message_subtype_rel. |
mail.thread | The abstract mixin a model inherits to get the fields below. |
Add chatter to a model
Section titled “Add chatter to a model”Inherit the mail.thread mixin, as an Odoo addon writes _inherit = ['mail.thread']. Your addon
depends on mail (depends = ["base", "mail"] in manifest.toml and in erp_sdk::addon!).
A native addon names the mixin by its Rust type, on a new model or on an extension of a model another addon owns:
use erp_addon_mail::MailThread;use erp_addon_project::Project;use erp_sdk::prelude::*;
erp_sdk::addon!(name = "helpdesk", depends = ["base", "mail", "project"]);
#[model(name = "helpdesk.ticket", description = "Ticket", inherit = [MailThread])]pub struct Ticket { #[field(char, required = true)] pub name: Option<Arc<str>>,}
// another addon's model gets the mixin without editing that addon (res.partner already has it// from `mail`); `Project` stands for a model of the `project` addon this one depends on (illustrative)#[extend(Project, addon = "helpdesk", inherit = [MailThread])]pub struct ProjectThread {}A data-only addon names the mixin by its model name in models/*.toml:
[[model]]name = "x_visit"description = "Visit"inherit = ["mail.thread"]
[[model.field]]name = "name"type = "char"Inside one addon, declarations compose in source order: by file path, then by line. An extension
of a model your addon also defines must therefore sit in a file that sorts after the definition (the
mail addon keeps the mixin in mail_thread.rs, before res_partner.rs).
The model then has three fields from the mixin:
| Field | Type | Value |
|---|---|---|
message_ids | one2many to mail.message | the record’s messages, user-specific notifications excluded; a caller sees only the messages the access rules let them read (none for a non-system user until the thread-access slice) |
message_follower_ids | one2many to mail.followers | the record’s follower rows; internal users only (base.group_user) |
message_partner_ids | many2many to res.partner, computed | the partners of the follower rows; writing it follows the added partners and unfollows the removed ones (internal users only) |
res.partner, res.company, and res.users inherit the mixin once mail is installed, and their standard form views carry <chatter/>. When product is installed alongside mail, the bridge addon product_mail (erp-addon-product-mail, auto_install = true) adds mail.thread inheritance and form view <chatter/> to product.template and product.product.
The documents of the business applications get their thread the same way, from bridge addons that
install with mail (each auto_install = true), so account, purchase and stock stay installable
without messaging:
| Bridge | Model | Mixins | Forms with <chatter/> | Tracked fields | Posting needs |
|---|---|---|---|---|---|
account_mail | account.move | thread, activities | account.view_invoice_form, account.view_move_form | name, ref, date, state, move_type, partner_id, currency_id, amount_untaxed, payment_state | read |
purchase_mail | purchase.order | thread, activities | purchase.purchase_order_form | partner_id, state, locked, amount_untaxed, user_id | read |
stock_mail | stock.picking | thread, activities | stock.view_picking_form | state, scheduled_date, date_done, picking_type_id, partner_id, user_id | write (the thread’s default) |
A bridge re-declares a field with only tracking = true (#[field(selection, tracking = true)]); the
registry merges it attribute by attribute, so every other attribute stays the defining addon’s
(docs/addon-guide/tracking.md). The thread shows the changes as history lines (Record
history); a status the inventory statements derive from the moves is reported by
the status operations themselves.
An auto-install bridge installs when mail or the application is installed after the other. On a
database that already has both, upgrading does not install it: an administrator installs it from
Addons (Accounting Mail Bridge, Purchase Mail Bridge, Inventory Mail Bridge).
Deleting a record of the model deletes its messages and followers. They point at the record through
model/res_id, which no foreign key covers, so the mixin’s unlink override removes them after
the record itself is deleted. A caller who may not delete the record deletes nothing.
Change what a thread shows
Section titled “Change what a thread shows”Three dispatched methods decide what the thread loading below shows for a model. A model
overrides them, as it overrides message_post:
| Method | Default | Override to |
|---|---|---|
_get_customer_portal_message_types() | auto_comment, comment, email, email_outgoing | change the message types a user outside the internal group sees on the thread |
_store_thread_fields(facts) on the model | can_write, can_post and, when asked for, default_subject | add facts about the record with ThreadFacts::set (a name set twice is a Programming error) |
_to_store(fields) on mail.message | the message fields of the store schema and the subtypes the messages name | change a value of a field the schema declares |
use erp_addon_mail::{MailThread, ThreadFacts};use erp_sdk::prelude::*;
erp_sdk::addon!(name = "helpdesk", depends = ["base", "mail"]);
#[model(name = "helpdesk.ticket", description = "Ticket", inherit = [MailThread])]pub struct Ticket { #[field(char, required = true)] pub name: Option<Arc<str>>, #[field(char)] pub priority: Option<Arc<str>>,}
#[methods(Ticket, addon = "helpdesk")]impl Ticket { /// Customers also see the automated notifications posted on a ticket. #[method(override)] async fn _get_customer_portal_message_types( this: &RecordSet<Ticket>, tx: &mut Transaction, sup: Super, ) -> Result<Vec<String>> { let mut types: Vec<String> = sup.call(tx, this.as_records(), ()).await?; types.push("notification".to_owned()); Ok(types) }
/// The thread facts of a ticket carry its priority (the `thread` topic's `data.thread`). #[method(override)] async fn _store_thread_fields( this: &RecordSet<Ticket>, tx: &mut Transaction, facts: ThreadFacts, sup: Super, ) -> Result<ThreadFacts> { let mut facts: ThreadFacts = sup.call(tx, this.as_records(), (facts,)).await?; let rows = this .as_records() .read_with(tx, &["priority"], erp_sdk::Load::Raw) .await?; let priority = match rows.first().and_then(|row| row.get("priority")) { Some(Value::Str(priority)) => priority.to_string(), Some(Value::False) => String::new(), other => return Err(Error::invariant(format!("priority is not text: {other:?}"))), }; facts.set("priority", erp_sdk::serde_json::json!(priority))?; Ok(facts) }}The example above is compiled by addons/mail/tests/chatter_guide.rs. What an override reads or sends counts against the
budget of the topic that calls it (7 statements for thread.messages, 12 for thread); a topic over its budget fails the call
with a Programming error, so keep an override to the statements it needs (batch, never one per record). A field on a message or a
follower reaches the client only when the store schema declares it, and until
installed-only schema filtering exists only the mail addon may contribute schema parts (the linked registry
refuses a part of another addon with an error that says so). Today an override of the message’s _to_store can
change a value of a field mail declares, not add a new field; a fact on the thread is a document key and needs no
schema.
Record history
Section titled “Record history”Every model that inherits MailThread gets its history with no code of its own:
- Creation line. A record created through the ORM gets one internal note, “model description
created” (
Ticket created), authored by the creating user’s contact. - Changes. A write that changes fields declared
tracking = truegives one history message per record and write (message_type = "tracking", subtypemail.mt_note, internal), authored by the writer’s contact. Itstrackingvalue lists each changed field: name, label, type, old and new value, and display text for selections (the label), booleans (Yes/No) and relational fields (the display names when written). A datetime has no display text: the client shows it in the reader’s time zone. A display text equal to the raw value (a char, text or date) is not stored a second time. A text value is stored up to the system parametermail.tracking_value_max_chars(characters; unset or 0 is the default 2,000, floor 100, hard bound 100,000; a stored value outside them fails the write by name) and a longer one is cut there and ends with…. - A field with
groupsis shown only to readers in those groups (SPEC-MAIL-063); the thread drops the other changes from the message when it loads. Each change keeps the field’s groups as they were at the write, so the change of a restricted field stays restricted once its addon is uninstalled; a change stored before the groups were kept, of a field no longer declared, is shown to nobody. The storedmail.message.trackingvalue is closed to every user (groups = "."): a genericread,search_read, domain, grouping or export that names it is refused, so the thread loading (_to_store) is the only way to the values. - The context keys
mail_create_nolog(no creation line) andtracking_disable(no line at all) are for server-side code such as imports: both are server-only, so an RPC call that sends one is refused withcontext key '<key>' cannot be set by the caller.
#[model(name = "helpdesk.ticket", description = "Ticket", inherit = [MailThread])]pub struct Ticket { #[field(selection, selection = [("new", "New"), ("done", "Done")], tracking = true)] pub stage: Option<Arc<str>>,}The lines are written at commit by the mail addon’s precommit hook (erp_addon_mail::TRACKING_HOOK,
registered by the served process), all records and fields of a commit in a fixed number of statements.
Shortcut: a creation line written at commit gets a higher id than a message posted on the new record
in the same transaction, so it can sort after it.
Three overridable methods of the mixin change what is written; each takes the records of one model:
| Method | Default | Override to |
|---|---|---|
_creation_message() → BTreeMap<id, String> | “description created” for every record | change the creation text; leave a record out to write no line |
_track_subtype(changed) → BTreeMap<id, String> | empty: every history message is a mail.mt_note | name a subtype by external id (sale.mt_order_confirmed) for a record whose changed fields call for it; an unknown id fails the commit |
_track_body(changed) → BTreeMap<id, String> | empty: no body | add a plain-text body next to the tracked values (it is escaped) |
changed maps each record id to the names of its changed tracked fields.
#[methods(Ticket, addon = "helpdesk")]impl Ticket { #[method(override)] async fn _creation_message(this: &RecordSet<Ticket>, _tx: &mut Transaction, _sup: Super) -> Result<BTreeMap<i64, String>> { Ok(this.as_records().ids().into_iter().map(|id| (id, "Ticket opened".to_owned())).collect()) }
#[method(override)] async fn _track_subtype(_this: &RecordSet<Ticket>, _tx: &mut Transaction, changed: BTreeMap<i64, Vec<String>>, _sup: Super) -> Result<BTreeMap<i64, String>> { Ok(changed.into_iter() .filter(|(_, fields)| fields.iter().any(|f| f == "stage")) .map(|(id, _)| (id, "helpdesk.mt_ticket_stage".to_owned())) .collect()) }
#[method(override)] async fn _track_body(_this: &RecordSet<Ticket>, _tx: &mut Transaction, changed: BTreeMap<i64, Vec<String>>, _sup: Super) -> Result<BTreeMap<i64, String>> { Ok(changed.into_keys().map(|id| (id, "Moved on the board".to_owned())).collect()) }}crates/erp-test-models/tests/mail_history.rs runs these overrides on a model that only inherits the
mixin.
A status written by SQL. Code that sets a tracked field with its own statement (posting, which
writes the state, date and number of an entry; matching, which writes an invoice’s payment status; the
inventory triggers) reports the change with Transaction::track_external(records, field, [(id, old, new)]). The history comes out of the same consumer as an ORM write. The call runs no statement, and
it does nothing when no installed addon tracks the field, so an application addon calls it without
depending on mail. When the old value has to be read first, ask tx.tracks(records, field) and read
only when it says yes:
set_state(tx, &pairs, "posted").await?;tx.track_external(moves, "state", headers.iter().map(|h| (h.id, old(h), Cell::Str("posted".into()))))?;Load a thread into the client (store topics)
Section titled “Load a thread into the client (store topics)”The chatter loads a thread with two topics of mail.store.store_fetch (Add a store topic),
next to whatever else the screen needs, in one call with one as-of. There is no separate load method:
{"wire": 1, "topics": [ {"name": "thread", "params": {"model": "helpdesk.ticket", "id": 5, "followers": true, "default_subject": true}}, {"name": "thread.messages", "params": {"model": "helpdesk.ticket", "id": 5, "before": 120, "limit": 30}}]}| Topic | Params | Slot data |
|---|---|---|
thread.messages | model, id, at most one of before, after, around (a message id), limit 1 to 100 (default 30) | {model, id, message_ids, has_more_before, has_more_after}; message_ids newest first |
thread | model, id, messages (default true) with limit, followers with followers_limit (1 to 100), default_subject, attachments with attachments_limit (1 to 100) | {thread: {model, id, can_write, can_post, default_subject?, attachment_count?, …}, messages?: {message_ids, has_more_before, has_more_after}, followers?: {count, follower_ids, self_follower_id, next_after}, attachments?: {attachment_ids, has_more}} |
Paging is by message id, newest first: no cursor is the newest page; before lists the older messages; after
the nearest newer ones; around the message and its neighbours (the older side takes the odd one). A page
that reaches an end of the thread is shorter than the limit. has_more_before and has_more_after say
whether more messages lie beyond the page; for a before page has_more_after is true (the cursor message,
which the caller holds, lies that way), and likewise has_more_before for an after page. A limit over 100
is refused, not clamped.
The store holds the page’s mail.message records (body, subject, message_type, subtype_id,
author_id, parent_id, date, is_internal, attachment_ids, res_model, res_id; a page carries no
recipients), the mail.message.subtype records they name, the ir.attachment records of their files and, for
the follower panel, the mail.followers records of the page and of the caller’s own row. Partner names are not in
it: partners come from a partner topic. See Files on messages for the attachment records.
Who sees what:
| Caller | Result |
|---|---|
| internal user who may read the record | every message the mail.message rules let it read; with followers, the follower panel |
| portal user who may read the record | the same rules plus the customer message types; followers is denied |
| a record the caller may not read, or that does not exist | that slot is denied with one message, the other topics answer, no message of the thread is in the payload |
| public user | denied |
| a name that is not an installed thread model | the whole call is refused (Validation) |
Direct mail.message reads have explicit author, recipient and notified-partner alternatives in
addition to document-reader access. Seeing one such shared message does not grant access to the
parent thread: thread and thread.messages still check the parent before loading their panels.
Their denied slots contribute no records to the shared store, while allowed topics in the same
request can answer normally.
Direct mail.followers reads are broader: the installed internal-user grant permits follower rows
independently of parent access. Do not use that grant as authorization to load a thread. Its related
name and email fields retain the reader’s company boundary under ADR 0044 rule 6; a follower row
can be readable while those related values are refused. Reading the parent’s message_partner_ids
or using thread_followers still requires access to that parent. Native acceptance for these paths
is in crates/erp-cli/tests/multiuser_mail_access.rs (partial SPEC-HUMAN-033 coverage).
Panels of the chatter that are not built yet (activities, scheduled_messages,
suggested_recipients, contact_fields, has_pinned_messages) refuse the call by name when asked for as true,
so a client never mistakes a missing panel for an empty one. The topics read only, on the primary; they never mark a message read
(that is a separate write call). Budgets: thread.messages sends at most 6 statements (7 for around, which
runs two searches) and thread at most 11, whatever the page size or the number of files; the one statement that
resolves the caller’s groups is paid once per call, per topic after its audience check and outside the topic’s span
(StoreTopic::needs_groups), and is not counted in a topic’s budget, so the whole call is one more (6, 7 for around,
and 9; snapshot excluded). Note: a file posted with an internal note belongs to the record, so the panel lists it for a portal reader of the record although the note, and the file’s link to it, are not in that reader’s page. limit and followers_limit are ignored when their panel (messages, followers) is off; next_after of the follower panel is set only while more followers exist than the page holds.
Files on messages
Section titled “Files on messages”A message links its files through mail.message.attachment_ids (the relation message_attachment_rel, as Odoo’s).
The files belong to the record (ir.attachment res_model and res_id); the link says which message they came
with. A message page and the thread topic carry them as store records:
| Where | What |
|---|---|
each mail.message record | attachment_ids: the ids of its files, ascending, empty when none. A file linked to a message but belonging to another record, or bound to a field, is not listed |
ir.attachment records | name, mimetype, file_size, checksum (the SHA-1 of the content), type (binary or url) and url; never the content, and no access token or route until scoped principals exist |
thread with attachments | data.attachments = {attachment_ids, has_more}: the newest files of the record, at most attachments_limit (default and cap 100), and the thread fact attachment_count, the exact number of the record’s files |
The files of a page are one statement however many messages and files there are, and the panel is one more. A portal reader gets the files of the messages its rules list, so an internal note’s files stay out; the panel lists the record’s files for any reader of the record, as Odoo’s panel search does. Odoo reads a readable message’s files with privileges; the store does the same, bounded by the same-record rule above.
To add a field to the file records, override mail.message._to_store and set fields of ir.attachment through
StoreFields::set (the schema must declare them; today that is mail’s own part). Posting files is under
Post a message.
Follower methods
Section titled “Follower methods”Call them on records of any model that inherits the mixin, for example with the untyped call:
let page: Records = ticket.call(tx, "followers", (None::<i64>, 50_u32)).await?;ticket.call::<_, ()>(tx, "follow", (vec![partner_id], None::<Vec<i64>>)).await?;ticket.call::<_, ()>(tx, "follow", (vec![partner_id], Some(vec![comment_subtype_id]))).await?;ticket.call::<_, ()>(tx, "unfollow", (vec![partner_id],)).await?;ticket.call::<_, ()>(tx, "set_subtypes", (partner_id, vec![comment_subtype_id])).await?;| Method | What it does | Access | Statements |
|---|---|---|---|
followers(after, limit) | One record’s follower records, oldest first; at most limit (1 to 100) after the follower id after. | read on the record | at most 3 (tested as the superuser only) |
follow(partner_ids, subtype_ids) | The partners follow the records (Odoo message_subscribe). Without subtype ids (or an empty list), partners that follow already are left untouched and the missing ones get the model’s default subtypes: all of them, or the external ones for share partners: a partner counts as internal when it has an active user that is not a share user (res.users.share); a partner with no such user is a share partner, as in Odoo. The superuser’s partner always counts as internal, although the superuser is archived (Odoo forces it non-share; ADR 0149 decision 3). With subtype ids, every listed partner ends with exactly those subtypes, existing followers included. Only active partners are followed; inactive ones are dropped without an error. | write on the records to follow another partner; read to follow only your own partner, and not as a public user | above the budget of 3 today (8 for default subtypes and 9 for an explicit replace, flush included, as the superuser) |
unfollow(partner_ids) | The partners stop following the records. Partners that do not follow are ignored. | write on the records; removing only your own partner needs read when you are not an internal user, nothing when you are | above the budget of 3 today (ceiling 5, as the superuser; the count does not depend on the number of models inheriting the mixin, which follower_statements_do_not_grow_with_thread_models checks) |
set_subtypes(partner_id, subtype_ids) | Replaces the subtypes a follower of one record receives. Missing when the partner does not follow. The write is pending until the next flush. | write on the record; read for your own partner | above the budget of 3 today (6, flush included, as the superuser: 5 plus the subtype id check) |
Each method takes at most 1000 ids per call and refuses non-positive ids with a Validation error.
Asking whether you are an internal user (or a public one, for follow of your own partner) goes to
the access policy; a policy that cannot answer makes the call fail with its error instead of
guessing.
Subtype ids are validated before anything is written, by set_subtypes and by follow with subtype
ids: each must be an existing mail.message.subtype whose res_model is empty or the followed
record’s model. Otherwise the call fails with a Validation error naming the ids, as in
Unknown subtype ids for <model>: 7, 9. ..., never with a foreign-key failure at flush.
set_subtypes(partner, []) is refused with Validation “Choose at least one subtype, or
unfollow.” and leaves the follower as it was. Odoo’s follower editor unfollows when no subtype is
chosen, and follow without subtypes keeps the follower and adds defaults only for missing ones,
so the call states which of the two you mean: call unfollow to stop, or pass subtypes.
Two differences from Odoo’s message_subscribe. When your own partner is the only one asked for
and you may not read the record (or you are a public user), Odoo returns False and does nothing;
follow fails with an Access error instead. And Odoo gives the current user’s own partner the
default subtypes without asking whether it is a share partner; follow asks, so a share partner
never receives the internal default subtypes, also when it follows itself or when the call runs
under sudo. In Odoo default_subtypes searches as the caller, and the public subtype rule
(mail/security/ir.access.csv:118) already hides internal subtypes from portal users, so the
difference shows only in sudo calls. Both are recorded as Parity: divergent on SPEC-MAIL-027 and
029 (ADR 0149, docs/adr/0149-mail-follow-refusals-and-share-defaults.md).
A user can subscribe themselves to an internal subtype by id: the subtype check runs with privileges, as Odoo allows. Keeping portal users off internal subtypes is for the notify slice.
Writing message_partner_ids (for example Command::set) makes the record’s followers exactly
those partners: the added ones follow through follow with the default subtypes, the removed ones
through unfollow, each with its own access check. Adding or removing more than 1000 partners on one
record in one write fails with a Validation error that names message_partner_ids. Only internal users may write the field
(Access “Cannot write on message partners” otherwise).
The private method _insert_followers(partner_ids, subtype_ids, policy) (not reachable by RPC, no
access check; the caller checks) is Odoo’s _insert_followers: policy is skip, replace or
update. update adds the missing subtypes to existing followers and never removes one. A partner
that another transaction starts following at the same moment makes one of the two fail on the
unique key (Validation, “A partner can follow a document only once.”).
Why these methods cost more than the budget of three statements today (a performance target,
DEFERRED_PERFORMANCE under ADR 0065, lowered at milestone end), and what would bring them down,
is in docs/design/m4-mail-core-a1-store.md (“Assumptions and stops”).
Post a message
Section titled “Post a message”message_post (Odoo’s message_post) posts on one saved record of a model that inherits the mixin.
Build a PostRequest from the body and set what you need:
use erp_addon_mail::{Body, Mention, MentionTarget, PostRequest, PostSubtype, PostType, Posted};
let mut request = PostRequest::new(Body::Text("Thanks @Ann, shipped today.".to_owned()));request.message_type = PostType::Comment;request.subtype = PostSubtype::Comment;request.partner_ids = vec![customer_id];request.mentions = vec![Mention { start: 7, end: 11, target: MentionTarget::Partner(ann_id) }];request.client_uid = Some(client_uuid);let posted: Posted = ticket.call(tx, "message_post", (request,)).await?;| Request field | Default | Meaning |
|---|---|---|
body | (required) | Body::Text: the server escapes it (< becomes <) and renders the mentions. Body::Html is refused with a Validation error until HTML fields are sanitized. At most 1 MiB. |
subject | none | Subject line, at most 1 MiB. |
message_type | PostType::Notification | A PostType: Email, Comment, EmailOutgoing, Notification, AutoComment, OutOfOffice or Tracking. There is no user_notification variant: that is message_notify, not implemented yet. A selection value from a caller is parsed with str::parse::<PostType>(), which refuses user_notification and unknown values with a Validation error. The enum is #[non_exhaustive], because addons extend the selection in Odoo (for example sms). |
subtype | PostSubtype::Note (mail.mt_note) | Comment (mail.mt_comment), Id(id) or Xmlid("module.name"); the subtype must have no model or the record’s model. |
parent_id | none | A message of the same record. Without one (or with a message of another record), a flat thread (the default) replies to the newest comment or email among the record’s latest 200 messages, else to the newest message, user notifications excluded (Odoo’s rule). A thread that is not flat keeps no parent then. |
partner_ids | none | Explicit recipients, stored in partner_ids (archived partners included) and notified when active. At most 1000; each must exist. |
mentions | none | Byte spans of the text body, each with a target. The server wraps each span in an anchor to the partner; the mentioned partner is stored with the explicit recipients and notified. Only MentionTarget::Partner is accepted on a record thread; channel, role, everyone and here mentions are refused (they are not available yet). At most 100; spans must not overlap. A link typed into the text is just text and reaches nobody. |
silent | false | Stored on the message and returned, for the later push job (ADR 0148 D5.5). |
attachment_ids | none | Files to post with the message, at most 100, duplicates fold: ids of files the caller uploaded for the composer (NewAttachment::pending_in(COMPOSER_MODEL), record 0), which the post moves onto the record, or, for an internal user only, files already on the record (a caller outside the internal group, a portal user for example, may name only their own composer files, as in Odoo). Any other id (another user’s composer file, a file of another record, a field-bound file, a missing id) refuses the post with an Access error that names the ids, and nothing is written; a non-positive id or more than 100 ids is a Validation error. The files are claimed through attachments::adopt after the post access check, so a portal user may post their own file on a record they may only read. A replayed client_uid ignores the ids. Odoo’s post route refuses a file the caller may not write (or holds no ownership token for), and its model step keeps only a non-internal caller’s own composer files; here a non-internal caller’s post that names a file already on the record is refused by name, and an internal caller needs write access to the record for such a file (on a contact, where post access is read, a reader may post but not link files already there). |
client_uid | none | Your id for this post. Posting again with the same id, as the same user on the same record, returns the stored message with replayed = true and posts nothing. Used by another user or on another record, it is a Validation error that confirms the id is taken but does not reveal the other post’s content or author. Two transactions posting the same id at the same moment: one fails on the unique key. |
options.autofollow_recipients | false | The explicit and mentioned partners follow the record first, through follow (needs write access). Odoo’s mail_post_autofollow. |
options.skip_author_subscribe | false | Odoo’s mail_post_autofollow_author_skip. |
What happens:
- Access: the record must allow the operation that the method
_mail_post_accessreturns: write by default, read onres.partner. Override it on your model to change it, as Odoo’s_mail_post_accessattribute._mail_flat_thread(default true) is overridable the same way. - The author is the current user’s partner. A user without a partner cannot post (an invariant
error). The superuser created with the database has no partner yet; its link to
base.partner_rootis not available yet, and its error says so. The message reaches the active partners that follow the record with the message’s subtype (an internal subtype reaches internal partners only), plus the active explicit and mentioned partners, never the author.Posted.notified_partner_idslists them; the message keeps them innotified_partner_ids. Inbox rows, email and bus events come with later slices. The files ofattachment_idsare claimed for the record and linked to the message (see the request table). - A comment (
message_typeother thanNotification,AutoCommentandOutOfOffice) undermail.mt_commentmakes an author who is an active internal user follow the record with the default subtypes, unless they follow already. - The Message-Id is
<uuid-<record id>-<model>@<database>>(the database name when it is a valid address part, elseerpforall.invalid). _message_post_after_hook(message_id)runs last; override it to act on the new message.
Statements: 5 for a comment by a user who already follows, with a client_uid and 5, 50 or 500
followers (flush included; measured on a build host under a test policy whose access check issues no
statement): the context read, the
recipient read, the ir.default lookup of the message create, the message INSERT and one
INSERT of all notified partners. The count does not grow with the followers. A replayed
client_uid costs 1. Explicit recipients add the partner_ids rows, the author’s first comment adds
the follower create, and a real access policy adds its own check. The §5.1 target of
docs/design/communication.md is a milestone-end performance target (ADR 0065).
_message_log_batch(bodies) (private, no access check: the caller checks) writes one internal note
per record without notifying anyone, as Odoo’s: bodies maps record ids to text, the subtype is
mail.mt_note, is_internal is set and all notes are created in one ORM call (the statement count does not depend on the number of records). The ids must be saved and unique: an unsaved or repeated id is a Validation error naming it. The current user must have a res.users row with a partner: a post or a log by a user without one fails with an Invariant error naming the user, and nothing is written (a message always has an author).
Call the thread from the client (JSON-2)
Section titled “Call the thread from the client (JSON-2)”The Rust methods above (message_post, follow, unfollow, set_subtypes, followers) take typed
arguments and are not callable over RPC. A client calls six methods of the mixin instead, each of
them a validated wrapper that calls the Rust method through the method chain, so an addon that
overrides message_post or follow on its model is honoured, and answers with the records the call
touched as a store payload (Store wire). Every model that inherits mail.thread
has them; the ids are the record’s:
POST /json/2/<model>/thread_post {"ids": [5], "post": {...}}POST /json/2/<model>/thread_follow {"ids": [5], "partner_ids": [7], "subtype_ids": [1, 3]}POST /json/2/<model>/thread_unfollow {"ids": [5], "partner_ids": [7]}POST /json/2/<model>/thread_set_subtypes {"ids": [5], "partner_id": 7, "subtype_ids": [1, 3]}POST /json/2/<model>/thread_followers {"ids": [5], "after": 120, "limit": 50}POST /json/2/<model>/thread_subtypes {"ids": [5]}POST /json/2/<model>/thread_upload {"ids": [5], "name": "hello.txt", "mimetype": "text/plain", "data": "<base64>"}POST /json/2/<model>/thread_attach {"ids": [5], "name": "hello.txt", "mimetype": "text/plain", "data": "<base64>"}| Method | Effect | Answer |
|---|---|---|
thread_post(post) | write | {"message_id", "replayed", "notified_partner_ids", "store"} |
thread_follow(partner_ids, subtype_ids?) | write | {"store"} with the follower records of the named partners |
thread_unfollow(partner_ids) | write | {"store"} with a delete marker for each follower record removed |
thread_set_subtypes(partner_id, subtype_ids) | write | {"store"} with the follower record |
thread_followers(after?, limit?) | read | {"store", "follower_ids", "next_after"}: a keyset page, oldest first, limit 1 to 100 (default 100); next_after is the id to send as after for the next page and null on the last page |
thread_upload(name, data?, mimetype?, upload_id?) | write | {"attachment_id", "name", "mimetype", "file_size", "checksum"}: one bounded base64 file or ready staged upload for the composer; it waits as the caller’s own file until thread_post names its id in attachment_ids; a file never posted is removed after 24 hours; at most 50 wait per user; needs the post access of the record, refuses public callers |
thread_attach(name, data?, mimetype?, upload_id?) | write | the same answer, for a file attached to the record itself (the attachments panel); needs write access to the record |
thread_subtypes() | read | {"store", "subtype_ids"}: the subtypes the follower editor offers, in order |
Uploads travel as base64 in the JSON body and are held to the inline threshold of the attachment store
(attachments.inline_max_bytes, 2 KiB by default, at most 64 KiB): a larger file is refused with an
error saying the HTTP upload route does not exist yet. A client sends the file with
thread_upload, then thread_post with "attachment_ids": [attachment_id], and reads it back with the
thread topic (attachments: true) or the pages of thread.messages. Cases SPEC-MAIL-380..382.
store is the payload of ADR 0148 D2: records grouped by model, with the schema generation, the wire
major and the as-of snapshot descriptor of the answering transaction (a writing answer carries its own
xid and marks the fields it wrote). The models and fields it uses are mail.message (body as
HTML text, subject, message_type, subtype_id, author_id, parent_id, date, is_internal,
partner_ids, res_model, res_id), mail.followers (res_model, res_id, partner_id,
subtype_ids) and mail.message.subtype (name, internal) and res.partner (name). Every answer that names partners
(message authors and recipients, followers) carries their res.partner records, read once for the distinct ids through the caller’s
access rights; a partner the caller may not read is left out and the client shows its placeholder. The schema is erp_addon_mail::store::schema() with the
generation of the one messaging schema the mail addon owns (the registry of
Add a store topic: a thread answer, a store_fetch answer and the schema topic carry
the same token, which changes whenever a field is added). An addon cannot depend on the wire crate; it reaches it as erp_sdk::store_wire.
The post object
Section titled “The post object”post is a closed object. Every other key (author_id, email_from, model, res_id,
attachments, body_is_html, …) is refused with a Validation error that names the key and
lists the allowed ones; nothing is written.
{"ids": [5], "post": { "body": "Thanks Ann, shipped today.", "subject": "Order 42", "message_type": "comment", "subtype": "comment", "partner_ids": [7], "mentions": [{"start": 7, "end": 10, "partner_id": 9}], "silent": false, "client_uid": "5d1b2a54-3c58-4a9e-8f3a-6a0a4b6f2c11", "attachment_ids": [12, 13]}}| Key | Default | Meaning |
|---|---|---|
body | required | Text: a string, or {"text": "..."}. The server escapes it and renders the mentions as anchors. {"html": "..."} is refused until HTML fields are sanitized; markup sent as text is stored escaped. At most 1 MiB. |
subject | none | Text, at most 1 MiB. |
message_type | comment | comment or notification. The server makes every other type; user_notification and unknown values are refused. |
subtype | comment | "comment" (mail.mt_comment: “Send message”), "note" (mail.mt_note: “Log note”), an external id "module.name" or a subtype id; it must have no model or the record’s model. |
parent_id | none | A message of the same record, else the flat-thread rule of message_post applies. |
partner_ids | none | Partners to notify. At most 1000; each must be readable by the caller. |
mentions | none | {start, end, partner_id} byte spans of the text body. At most 100; whole characters; no overlap; each mentioned partner is notified like an explicit one and must be readable by the caller. |
silent | false | No push and no out-of-focus alert (ADR 0148 D5.5). |
attachment_ids | none | A list of file ids, as in the Rust request: the caller’s composer files, and for an internal user files already on the record; anything else is refused by name. The answer’s message record carries them. |
client_uid | none | A UUID of your choosing. A retry by the same user on the same record returns the stored message with "replayed": true and writes nothing; another user or record using it is refused. |
The defaults are those of the chatter composer, not of the Rust PostRequest::new (a notification
under the note subtype): omit message_type and subtype to “send a message”, send
"subtype": "note" to log a note. The author is always the caller’s partner. There is no key to
subscribe recipients: the post subscribes its author when the Rust rules do (a comment by an active
internal user who may write the record), and a caller who may only read the record never becomes a
follower by posting (Odoo’s controller does the same, thread.py:252-254).
Who may do what
Section titled “Who may do what”Internal means a member of base.group_user, public a member of base.group_public, portal anyone
else. The anonymous principal never reaches these methods: the RPC service refuses it first.
| Call | Internal | Portal | Public |
|---|---|---|---|
| post a comment | the access _mail_post_access names on the record (write; read on res.partner) | the same access, with the comment shape only | refused |
| log a note, choose another type or subtype | the same access | refused | refused |
| address or mention partners | readable partners only | refused | refused |
| post silently | allowed | refused | refused |
| follow, unfollow or set subtypes for oneself | read on the record | read on the record, subtypes it can see | refused |
| the same for another partner | write on the record | refused | refused |
| list followers | read on the record | refused | refused |
| list the editor’s subtypes | read on the record | read on the record; non-internal subtypes | refused |
A model decides whether portal users may post at all through its own record rules and
_mail_post_access: a portal user needs the post access on the record, which is write by default.
Refusals are Access errors that say what was asked, never a silent rewrite (Odoo forces the comment
shape for non-internal callers without telling them). A partner that does not exist and one the caller
may not read give the same message, so it does not reveal which exists. A portal caller is not told
who was notified (notified_partner_ids is left out of its answer) and does not become a follower.
Errors keep their kind on the wire: Validation is HTTP 422 (erp.exceptions.ValidationError),
Access is 403, Missing is 404. An error in the post object reads
argument 'post' of <model>.thread_post: <reason>.
// what a call looks like from a test or a Rust client of the JSON-2 servicelet response = service .call(RpcCall::json2( "/json/2/helpdesk.ticket/thread_post", serde_json::to_vec(&json!({"ids": [ticket], "post": {"body": "hello"}}))?, caller, )) .await;How the layer is tested, and what is not: crates/erp-test-models/tests/mail_rpc.rs runs every
case above through the RPC service on the production policy with two extension addons overriding
message_post of one model. Statement counts of the wrappers are not measured yet (the budgets of
docs/design/communication.md §15.2 are milestone-end targets, ADR 0065).
Who can read a message
Section titled “Who can read a message”Read access to mail.message comes from the rows of mail/security/ir.access.csv, on the
thread_access rule operator the addon declares:
- an internal user (
base.group_user) reads a message it wrote, one addressed to it (partner_ids), one it was notified of (notified_partner_ids) and any message of a document it can read (user notifications only through the recipient branches, as in Odoo); - a portal user reads the same, but never an internal message (
is_internal, an internal subtype) and never a tracking message; - a public user reads the non-internal messages of the documents it can read, and never tracking messages.
“A document it can read” is the document’s own record rules for the read operation, for every
model that inherits mail.thread, decided in the same statement as the listing: the policy
compiler adds one branch per such model, so a search over messages of many models is one query
and a model that shows up only on a later page is never missed. Nothing to declare on your model:
inherit the mixin and its read rules apply. Writing, posting and unlinking messages are not part
of these rows yet (they map to the document’s operations in a later slice).
An addon that ships its own message-like model declares its own operator the same way, see access-rules.md “Operators an addon declares”:
erp_sdk::rule_operator!(pub NOTE_ACCESS = "note_access" { addon: "helpdesk", model: "helpdesk.note", field: "res_id", inherits: "mail.thread", operations: [Read],});
fn main() { assert_eq!(NOTE_ACCESS.name(), "note_access"); assert_eq!(NOTE_ACCESS.field(), "res_id");}Scheduled messages
Section titled “Scheduled messages”mail.scheduled.message holds a message composed now and posted on a record’s thread later (Odoo’s
model of the same name, not mail.message.schedule, which only delays notifications). Any model
that inherits mail.thread has it for free. Users never touch the table: four methods require
base.group_user and write access to the record (Odoo’s res_access; not _mail_post_access:
a partner can be posted on with read access but a message cannot be scheduled on it), and then write
the row themselves. message_post still checks the post access when the message is sent.
use erp_addon_mail::{CommentOption, EditRequest, ScheduledMessageRequest};
let scheduled = env.records("mail.scheduled.message")?;let mut request = ScheduledMessageRequest::new("helpdesk.ticket", ticket_id, "We ship tomorrow", send_at);request.subject = Some("Shipping".to_owned());request.partner_ids = vec![customer_partner];let id: i64 = scheduled.call(tx, "schedule", (request,)).await?;
let row = scheduled.browse([id])?;let mut patch = EditRequest::new();patch.scheduled_date = Some(later); // a new date re-arms the deliveryrow.call::<_, ()>(tx, "edit", (patch,)).await?;let message_id: i64 = row.call(tx, "send_now", ()).await?; // or: row.call::<_, ()>(tx, "cancel", ()).await?| Method | Who | What |
|---|---|---|
schedule(request) | an internal user who may write the record | creates the row for the caller and queues its delivery job; returns the id |
edit(patch) | the creator, an internal user who may still write the record | changes text, recipients, note flag or date; a new date re-arms |
send_now() | the creator (an administrator who is not the creator is refused until audited elevation exists) | posts at once as the creator through message_post; a post error reaches the caller and the row stays |
cancel() | any internal user who may write the record | deletes the row and cancels its job |
A direct ORM create of a row is refused (it would have no job) and so is a direct write of
scheduled_date, arm_seq, state or failure_reason; the data is checked first, so a past date or
a model that is not a mail thread is refused on every path. Only these methods and the delivery job
write those fields, through a server-only marker an RPC or a client cannot set. At most 100
scheduled messages exist per record, enforced under concurrency by an advisory lock on the record
and a unique (record, slot) key; a scheduler that loses the race is repeated by the unit of work and
then gets the bound. Refusals, all typed: a model that is not a mail thread, a past date (A Scheduled Message cannot be scheduled in the past), unknown partners, more than 100 scheduled messages on one record, and the
options that are not available yet: attachments and Cc recipients. The body is plain text (it is escaped when sent; HTML waits for
sanitized HTML fields).
Delivery. One job per message on the durable queue (Background jobs), kind
mail.scheduled_message_send, due at the message’s date and run as the creator. Its idempotency key
is <id>:<generation>, and the payload names only the row: the text is read when the job runs, so
an edit is always honoured. cancel, a re-arm by edit and send_now cancel the row’s live job
with Transaction::job_cancel_by_key (Background jobs) and
assert what they found (one live job for a scheduled row; none for a failed row or a dead letter; a job held by a
claim in flight is a retryable 40001; no job at all is logged and the call goes on), so no stale job is left;
a job that still finds no row, or one of an older generation, does nothing.
Deleting a record deletes its rows and cancels all their jobs in one set-based cancel. A
scheduled row whose job has vanished from the queue (an expired dead letter, a job an
administrator discarded) is listed as failed with a fixed “no delivery job” reason, and cancel,
send_now and edit with a date still work on it. A date more than 365 days ahead is refused. The message is posted and the row deleted in one
transaction, so it is sent once even if two nodes race for the job or a node dies mid-run. To act when a
scheduled message has been posted (Odoo’s _message_created_hook), override
mail.scheduled.message _message_created_hook(message_id) and call super: it runs after
message_post, in the same transaction, for the job and for send_now, on a privileged (sudo)
recordset of the row, so an override has superuser rights and must not use the recordset for access
decisions; an error in it rolls the post back. The kind is a step kind, so send_due
can be overridden too. A binary that runs jobs requires the kind at its
build site with OrmBuilder::require_job_kinds(erp_addon_mail::job_kinds().iter()).
Failure. A post that raises an access, validation, user or missing error (the creator lost the
right to post, a recipient was deleted) rolls back and marks the row failed with a fixed reason for that kind of error (the raw error goes
to the server log, not to the record’s other writers); the row stays so nothing the user wrote is lost, and they can edit it with a new
date, send it now or cancel it. Any other error is retried by the queue and finally becomes a dead
letter, which the listing shows as failed. Odoo unlinks the draft and notifies the creator with
message_notify; here the draft stays (ADR 0154) and the creator is not told actively until
message_notify exists.
Listing. The store topic thread.scheduled (params model, res_id; internal users who may
write the record; a missing record is the same denial slot) lists a record’s scheduled messages by date for the chatter, at most 100;
more is a UserError (creation stops at the same bound). Deleting a record deletes its scheduled
messages. The RPC exposure of the four methods comes with the thread RPC. Design and cases: docs/design/m4-mail-scheduled.md, SPEC-MAIL-141..143
and SPEC-MAIL-364..372.
Default subtypes
Section titled “Default subtypes”mail.message.subtype method default_subtypes(model_name) returns the default subtypes of a model
(generic ones included) in subtype order, split into internal and external ones:
let defaults: DefaultSubtypes = subtypes.call(tx, "default_subtypes", ("helpdesk.ticket".to_owned(),)).await?;let for_portal = defaults.external();mail.mt_comment, mail.mt_note and mail.mt_activities are master records: deleting them, or
giving them a model or another internal value, is refused with a UserError.
Your addon ships its own subtypes as data records of mail.message.subtype with res_model set to
your model.
Add activities to a model
Section titled “Add activities to a model”Activities are things to do on a record: a call, a meeting, a to-do, with a deadline and an assignee.
Inherit mail.activity.mixin next to mail.thread (the done message and the assignee’s follow need the
chatter). The compiling example is Task in addons/mail/tests/activity.rs:
use erp_addon_mail::{MailActivityMixin, MailThread};use erp_sdk::prelude::*;
#[model( name = "helpdesk.ticket", description = "Ticket", inherit = [MailThread, MailActivityMixin])]pub struct Ticket { #[field(char, required = true)] pub name: Option<Arc<str>>,}The mixin adds activity_ids (the record’s active activities, nearest deadline first), and the derived
activity_state (overdue, today, planned or empty), activity_user_id, activity_date_deadline and
activity_summary. A model with an activity but without both mixins is refused when the activity is
created. res.partner does not have activities yet (the chatter integration adds them).
| Model | What it holds |
|---|---|
mail.activity.type | Kinds of activity with default summary, assignee and delay. Six default records (mail.mail_activity_data_email, _call, _meeting, _todo, _upload_document, _warning (archived)). Call, Meeting and To-Do cannot be deleted, To-Do cannot be archived; deleting a type moves its activities, archived ones too, to To-Do. |
mail.activity | One row per activity: res_model, res_id (empty for a personal to-do), type, summary, note (plain text), date_deadline, date_done, feedback, automated, user_id, active, and the computed state and can_write. |
Create and defaults. An activity without a type takes the first active type for its model (or for every
model) by sequence; without a summary, the type’s summary or name; without a deadline, today in the
environment’s time zone plus the type’s delay; without an assignee, the type’s default user, else the
current user. The assignee’s partner follows the record. Creating needs the record’s post access
(_mail_post_access: write, read on partners).
State. state is done once archived, else the deadline compared with today in the assignee’s time
zone (UTC without one). Archiving stamps date_done with today’s UTC date; unarchiving clears it.
Done. action_feedback(feedback, attachment_ids) posts a message on each record (subtype
mail.mt_activities, authored by the current user, plain text such as To-Do done (summary): feedback),
archives the activities and stores the feedback; action_done is the same without feedback. The message
is posted privileged, so an assignee who cannot write the record can still complete their activity;
anyone else needs write access to the record. action_feedback is exposed to RPC (write effect) for the
chatter’s activity card; action_done and the reschedule methods are not. Attachments on the feedback are refused with a validation
error until ir.attachment exists. action_reschedule_today, _tomorrow, _nextweek (the
Monday on or before a week from today) and _customdate(date) move active deadlines.
Automation helpers on the record: activity_schedule(ScheduleRequest) (automated by default),
activity_search, activity_reschedule, activity_feedback and activity_unlink take type external ids
(module.name); with the context key mail_activity_automation_skip they do nothing.
let mut request = ScheduleRequest::new();request.act_type_xmlid = Some("mail.mail_activity_data_call".to_owned());request.summary = Some("Call the customer".to_owned());let created: Option<Records> = ticket .call(tx, "activity_schedule", (request,)) .await?;Chatter data. activities_panel() on one record returns an ActivityPanel (the activities the caller may
read with type, assignee, state and can_write) in a number of statements that does not depend on how many
activities there are. It is a plain typed value; the activities store topic of ADR 0148 wraps it once that topic is available.
The activity menu. activity_groups(env, tx) (module activity_menu) returns the caller’s open activities
counted per model, and the JSON-2 method mail.activity.erp_activity_groups (read, model-level, no arguments)
returns the same as a map. It replaces the earlier activity_systray function. The scan is bounded: the caller’s
own open activities, newest first, at most mail.activity.systray.limit of them (unset or 0 is 1000; a negative
value or one above 10000 is a Validation error naming the parameter). Per record only the most urgent activity
counts (earliest deadline, then lowest id). The answer is
{ "activity_counter": int, "groups": [ { "model": str, "name": str, "addon": str | false, "domain": list, "overdue_count": int, "today_count": int, "planned_count": int, "total_count": int, "activity_ids": [int] } ] }name is the model’s registry label, addon the addon that first declared it, domain is
[["active", "in", [true, false]]] for a model with an active field (archived records keep their activities in
the menu) and [] otherwise, total_count is overdue plus today and activity_counter the sum of the totals.
Groups are ordered by name. Activities without a readable document (personal to-dos, documents a record rule
hides, models the caller has no read right on, deleted documents, unregistered models) are counted together in
the group mail.activity / “Other Activities”, which never carries a document model, id or name (an activity
on a mail.activity record itself counts there too, so no second group is keyed mail.activity). The
activity_ids of every group, the Other group included, are always the caller’s own activities. When the
caller’s selected companies are fewer than their own, a record that is readable with all their companies selected
is left out of every group. Access: the model-level read right on mail.activity is checked first, so public
and portal users get an Access error; the scan and every record filter run as the caller, and only the limit
parameter is read in superuser mode.
Opening a group. activity_group_action(env, tx, model, state) (JSON-2
mail.activity.erp_activity_group_action, read, model-level; arguments model and state) returns the window
action that opens one group of the menu in one state: state is all (overdue and today), overdue, today or
planned. The answer is a map with type ir.actions.act_window, the group’s name, res_model, target
current, views [[false, "list"], [false, "form"]], context {} and a literal domain: ["id", "in", ids]
followed by the group’s own domain. The ids come from the same scan as the counts, so their number is the
group’s count for that state (ActivityGroup::open_ids). For “Other Activities” (model = mail.activity) the
ids are the caller’s own activity ids, never the ids of hidden documents. The ids are a snapshot: the list that
opens searches again under the caller’s rules. Refusals are Validation errors: an unknown state, a model the
caller has no group for (one message, whether or not the model exists or is readable) and a state with more than
MAX_OPEN_RECORDS (1000) records, which is refused and never shortened. Public and portal users get an Access
error. mail also ships the window action mail.mail_activity_action_my (“My Activities”: list and form views of
mail.activity, domain [('user_id', '=', uid)]), the persisted action a client anchors such an opened list on.
Its list shows each activity’s stored res_name, which the assignee can already read; the RPC answer itself never
names a hidden document.
Who can see and change what (security/ir.access.csv): employees read an activity when it is assigned to
them or they can read its record (the activity_thread_access rule operator, the twin of thread_access),
update and delete one they created or are assigned, and create one; administrators have full access; types
are readable by employees. Not yet: the assignment notification message, bus events, plans, reminders,
chaining (“done and schedule next”), attachments and a searchable activity_state.
Adopt a streamed upload
Section titled “Adopt a streamed upload”The mail RPCs accept exactly one of data (legacy base64, bounded by the inline limit) or
upload_id (a ready upload staged by the same subject and actor). For example:
{"ids": [5], "name": "report.txt", "upload_id": "01234567-89ab-cdef-0123-456789abcdef"}Send that object to thread_upload for a composer file or thread_attach for a record-panel file.
Both return the existing {attachment_id, name, mimetype, file_size, checksum} shape. Composer
upload needs the record’s post permission; panel attachment needs write permission. A staged id
confers no permission to a record. Name and MIME hints never replace detected size, type or digest.
A post can adopt ready uploads directly alongside existing attachment ids:
{"ids": [5], "post": {"body": "Report", "client_uid": "abcdef01-2345-6789-abcd-ef0123456789", "attachment_ids": [12], "staged_uploads": [{"name": "report.txt", "upload_id": "01234567-89ab-cdef-0123-456789abcdef", "mimetype": "text/plain"}]}}staged_uploads is a closed list of descriptors: only name, upload_id and optional mimetype.
The combined input count is at most 100. Repeated staged ids are refused; distinct uploads with
identical bytes may deduplicate. Existing attachment-id duplicate handling remains unchanged.
All files and the message are adopted in one transaction; errors and rollback preserve usable
intents. Replaying a committed client_uid returns the original post without consuming the
supplied ids again. This runs through message_post, including addon overrides.
Typed callers set PostRequest::staged_uploads with StagedAttachment::new. Its metadata is
bounded; the attachment linker checks current ownership and expiry. A typed caller that catches
a post failure may commit other work: a post savepoint prevents partial adoption from surviving.
The 50-file waiting-composer cap is shared across keys and replicas; direct posts create no
committed waiting files. Old snapshots fail with serialization conflict and use normal RPC retry.
These are server RPC capabilities. Raw HTTP transport and the browser’s streaming controls remain separate upload packages; this delivery does not establish end-to-end large-file browser support.
Saved record notifications
Section titled “Saved record notifications”Addons that post through the native thread operation inherit the transactional erp_thread_changed notification. No additional table or data migration is required. Raw database writes do not run the posting hook. A new committed post emits a payload-free signal even if another node serves the reader. Normal direct reads of messages retain their ordinary access rules.
The signed-in shell includes thread_reconnect_ms. When the database has installed thread support and the server provides a thread feed, its two values are the configured initial and maximum reconnect delays in milliseconds. Otherwise the value is null. Nodes serving the same database must agree on these startup limits. The public sign-in page does not expose this policy. The client sends one JSON subscription with type, model, id, company and the signed shell csrf token. Browser code must not log the token. A resync frame asks the existing thread pager to load the authorized latest page. The tokens, message bodies, record identities and authors stay out of notification events.