Ejabberd message archiving and history playback

February 12, 2021 

When using ejabberd in a company for multi-user chat (see my earlier blog post) people will quickly start complaining that they missed discussions because they had been offline. Ejabberd does play back last 20 messages when user joins a room, but that is too little for an active chatroom. The simplistic approach is to set history_size in mod_muc settings in ejabberd.yml to a higher value:

mod_muc:
  history_size: 200
  --- snip ---

This simplistic approach should work with any XMPP clients.

A better way would be to use the Message Archiving module (mod_mam) as described in this blog post. First configure MaM in ejabberd.yml:

mod_mam:
  assume_mam_usage: true
  # Store all messages
  default: always

Then configure your chatrooms to use MaM:

ejabberdctl change_room_option private conference.chat.example.org allow_subscription true
ejabberdctl change_room_option private conference.chat.example.org mam true
ejabberdctl change_room_option private conference.chat.example.org persistent true

You may want to set these in mod_muc's default_room_options as well for all new rooms.

Too bad that some very common XMPP clients like Pidgin (or anything else based on libpurple, probably) do not support MaM.

Samuli Seppänen
Samuli Seppänen
Author archive
menucross-circle