Commit 4c15ac2e authored by JC Brand's avatar JC Brand

Add new config setting: `auto_join_private_chats`

parent 3fe2ff23
...@@ -31,7 +31,8 @@ ...@@ -31,7 +31,8 @@
- Removed `xhr_user_search` in favor of only accepting `xhr_user_search_url` as configuration option. - Removed `xhr_user_search` in favor of only accepting `xhr_user_search_url` as configuration option.
- The data returned from the `xhr_user_search_url` must now include the user's - The data returned from the `xhr_user_search_url` must now include the user's
`jid` instead of just an `id`. `jid` instead of just an `id`.
- New configuration setting [nickname](https://conversejs.org/docs/html/configurations.html#nickname) - New configuration settings [nickname](https://conversejs.org/docs/html/configurations.html#nickname)
and [auto_join_private_chats](https://conversejs.org/docs/html/configurations.html#auto-join-private-chats).
## Architectural changes ## Architectural changes
......
...@@ -343,6 +343,19 @@ auto_join_on_invite ...@@ -343,6 +343,19 @@ auto_join_on_invite
If true, the user will automatically join a chatroom on invite without any confirm. If true, the user will automatically join a chatroom on invite without any confirm.
auto_join_private_chats
-----------------------
* Default: ``[]``
Allows you to provide a list of user JIDs for private (i.e. single) chats that
should automatically be started upon login.
For example::
`['tom@example.org', 'dick@example.org', 'harry@example.org']`
auto_join_rooms auto_join_rooms
--------------- ---------------
......
This diff is collapsed.
...@@ -55,9 +55,17 @@ ...@@ -55,9 +55,17 @@
const { _converse } = this, const { _converse } = this,
{ __ } = _converse; { __ } = _converse;
// Configuration values for this plugin
// ====================================
// Refer to docs/source/configuration.rst for explanations of these
// configuration settings.
_converse.api.settings.update({
auto_join_private_chats: [],
});
_converse.api.promises.add([ _converse.api.promises.add([
'chatBoxesFetched', 'chatBoxesFetched',
'chatBoxesInitialized' 'chatBoxesInitialized',
'privateChatsAutoJoined'
]); ]);
function openChat (jid) { function openChat (jid) {
...@@ -709,8 +717,28 @@ ...@@ -709,8 +717,28 @@
return _converse.chatboxviews.get(chatbox.get('id')); return _converse.chatboxviews.get(chatbox.get('id'));
}; };
function autoJoinChats () {
/* Automatically join private chats, based on the
* "auto_join_private_chats" configuration setting.
*/
_.each(_converse.auto_join_private_chats, function (jid) {
if (_converse.chatboxes.where({'jid': jid}).length) {
return;
}
if (_.isString(jid)) {
_converse.api.chats.open(jid);
} else {
_converse.log(
'Invalid jid criteria specified for "auto_join_private_chats"',
Strophe.LogLevel.ERROR);
}
});
_converse.emit('privateChatsAutoJoined');
}
/************************ BEGIN Event Handlers ************************/ /************************ BEGIN Event Handlers ************************/
_converse.on('chatBoxesFetched', autoJoinChats);
_converse.on('addClientFeatures', () => { _converse.on('addClientFeatures', () => {
_converse.connection.disco.addFeature(Strophe.NS.HTTPUPLOAD); _converse.connection.disco.addFeature(Strophe.NS.HTTPUPLOAD);
_converse.connection.disco.addFeature(Strophe.NS.OUTOFBAND); _converse.connection.disco.addFeature(Strophe.NS.OUTOFBAND);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment