Add new MUC option auto_join_rooms.

Fixes #156
This commit is contained in:
JC Brand 2016-03-22 08:15:52 +00:00
parent fc7f50887a
commit 946e9fed5d
3 changed files with 34 additions and 5 deletions

View File

@ -1,6 +1,6 @@
# Changelog
## 0.11.0 (Unreleased)
## 1.0.0 (Unreleased)
- Add support for messages with type `headline`, often used for notifications
from the server. [jcbrand]
@ -18,6 +18,8 @@
- Use `rel=noopener` with links that contain `target=_blank` to prevent potential
phishing attacks. [More info here](https://mathiasbynens.github.io/rel-noopener/)
[jcbrand]
- #156 Add the option `auto_join_rooms` which allows you to automatically
connect to certain rooms once logged in. [jcbrand]
- #261 `show_controlbox_by_default` config not working [diditopher]
- #443 HTML5 notifications of received messages [jcbrand]
- #534 Updated Russian translation [badfiles]

View File

@ -256,6 +256,23 @@ auto_join_on_invite
If true, the user will automatically join a chatroom on invite without any confirm.
auto_join_rooms
---------------
* Default: ``[]``
This settings allows you to provide a list of groupchat conversations to be
automatically joined once the user has logged in.
You can either specify a simple list of room JIDs, in which case your nickname
will be taken from your JID, or you can specify a list of maps, where each map
specifies the room's JID and the nickname that should be used.
For example:
`[{'jid': 'room@example.org', 'nick': 'WizardKing69' }]`
.. _`bosh-service-url`:
bosh_service_url

View File

@ -150,7 +150,8 @@
this.updateSettings({
allow_muc: true,
auto_join_on_invite: false, // Auto-join chatroom on invite
auto_join_rooms: [], // List of JIDs of rooms to be joined upon login
auto_join_rooms: [], // List of maps {'jid': 'room@example.org', 'nick': 'WizardKing69' },
// providing room jids and nicks or simply a list JIDs.
auto_list_rooms: false,
hide_muc_server: false,
muc_history_max_stanzas: undefined, // Takes an integer, limits the amount of messages to fetch from chat room's history
@ -1327,15 +1328,24 @@
}
}
};
var registerInviteHandler = function () {
var onConnected = function () {
converse.connection.addHandler(
function (message) {
converse.onDirectMUCInvitation(message);
return true;
}, 'jabber:x:conference', 'message');
_.each(converse.auto_join_rooms, function (room) {
if (typeof room === 'string') {
converse_api.rooms.open(room);
} else if (typeof room === 'object') {
converse_api.rooms.open(room.jid, room.nick);
} else {
converse.log('Invalid room criteria specified for "auto_join_rooms"', 'error');
}
});
};
converse.on('connected', registerInviteHandler);
converse.on('reconnected', registerInviteHandler);
converse.on('connected', onConnected);
converse.on('reconnected', onConnected);
/* ------------------------------------------------------------ */