Persistence for user Multi-User Chat in Converse.js

533 Views Asked by At

I want to retrieve all chat conversations from ejabberd, even after I logout, close the browser and login again. Please suggest any way to do it. I am using converse.js. Should I add something in converse configuration to retrieve the chat conversation ?

Basically, I want Facebook kind of chat where we can retrieve chat conversation between each user after its logged in.

Here is my converse.js config:

converse.initialize({
                        websocket_url: webSocketUrl, // ConnectionUrl
                        keepalive: true,
                        message_carbons: true,
                        play_sounds: true,
                        auto_login: true,
                        jid: user,
                        password: password,                        
                        show_controlbox_by_default: false,
                        auto_list_rooms:true,
                        allow_logout: false,
                        allow_registration: false,
                    });
1

There are 1 best solutions below

1
On BEST ANSWER

Converse.js supports the XMPP extension XEP-0313 Message Archive Management (MAM).

You need to make sure that your XMPP server supports MAM. Ejabberd 15.06 has support for it. You'll need to turn it on in Ejabberd's configuration file.

In converse.js, you want to pass in a value of roster or always to message_archiving when you call converse.initialize.

For example:

converse.initialize({
                   // Your other options go here...
                   message_archiving: 'always'
                });

roster means that only message to and from contacts in your roster are archived. always of course means that messages are always archived.

There is also the related option archived_messages_page_size, which you can use to set how many messages are fetched at a time.