Add an indicator to message for permanent offline message - liangdefeng/ejabberd GitHub Wiki
In current Ejabberd's implementation, the offline messages will be automatically deleted after a certain days. However, in some situation, we want to keep some of the offline messages forever. For example, if messages contain persist event as below, the message won't be deleted by the existing offline message deletion mechanism.
<message to='[email protected]' id='GabberMessage43'>
<body>Neither, fair saint, if either thee dislike.</body>
<x xmlns='jabber:x:event'>
<persist/>
</x>
</message>
To implement the above function, we need to extends the x event. According to XEP-0022(https://xmpp.org/extensions/xep-0022.html), x event only supports offline, delivered, displayed, composing and id. So we need to add an additional element - persist, which indicates the message won't be deleted as offline message.
<x xmlns='jabber:x:event'>
<persist/>
</x>
When server receives a message with persist x event, and the message becomes offline message. Server will store it in a separate table.