mod_mam Message Archives

This module stores messages in per-user archives, and allows clients that implement XEP-0313 to access the archive.

This can be used to synchronize conversations between multiple clients even if they are offline when the conversation happened, or for clients to display a conversation history browser to the user.

mod_carbons is a related module that is used for synchronization of conversations between online clients.


Add "mam" to your modules_enabled list:


Option summary

option type default
default_archive_policy boolean or "roster" true
archive_expires_after string "1w"
archive_cleanup_interval number 4*60*60
max_archive_query_results number 50
archive_store string "archive"
dont_archive_namespaces set { "" }
mam_smart_enable boolean false

Configuring a storage backend

mod_mam uses the store "archive". See Prosodys data storage documentation for information on how to configure storage.

For example, to use mod_storage_sql only for MAM archives:

If no archive-capable storage backend can be opened then an in-memory one will be used as fallback.

Legacy message archive

Early versions of mod_mam (which were available in prosody-modules) stored data in a store called 'archive2'. This store is now just called 'archive' in 0.10.

mod_mam in 0.10 can be instructed to use the older store name if you still have data there.

Memory-only storage

For performance and privacy reasons, you might prefer to keep messages in memory only. This works best on smaller servers, and obviously if Prosody restarts then it is possible that some clients may not receive messages. Note that if all clients are offline, messages will still be stored via mod_offline.

Message matching policy

The MAM protocol includes a way for clients to control what messages should be stored. This allows users to enable or disable archiving by default or for specific contacts.

The server can specify a default policy using default_archive_policy.

default_archive_policy = Meaning
false Store no messages.
"roster" Store messages to/from contacts in the users roster.
true Store all messages. This is the default.

If mam_smart_enable is set to true then archiving is disabled until the user either queries their archive or uses the MAM preferences protocol. Once they do, their settings are initialized to the value of default_archive_policy. This setting was added in 0.10.1.

Archive expiry

Messages in the archive will expire after some time, by default one week. This can be changed by setting archive_expires_after:

The format is an integer number of seconds or a multiple of a period given by a suffix that can be one of d (day), w (week), m (month) or y (year). No multiplier means seconds.

Query size limits

max_archive_query_results = 20;

This is the largest number of messages that are allowed to be retrieved in one request page. A query that does not fit in one page will include a reference to the next page, letting clients page through the result set. Setting large number is not recommended, as Prosody will be blocked while processing the request and will not be able to do anything else.