|
@@ -413,26 +413,31 @@ export default class XMPP extends Listenable {
|
413
|
413
|
* @param options
|
414
|
414
|
*/
|
415
|
415
|
createRoom(roomName, options) {
|
416
|
|
- // By default MUC nickname is the resource part of the JID
|
417
|
|
- let mucNickname = Strophe.getNodeFromJid(this.connection.jid);
|
418
|
416
|
let roomjid = `${roomName}@${this.options.hosts.muc}/`;
|
419
|
|
- const cfgNickname
|
420
|
|
- = options.useNicks && options.nick ? options.nick : null;
|
421
|
417
|
|
422
|
|
- if (cfgNickname) {
|
423
|
|
- // Use nick if it's defined
|
424
|
|
- mucNickname = options.nick;
|
|
418
|
+ let mucNickname;
|
|
419
|
+
|
|
420
|
+ // We use the room nickname (the resourcepart of the occupant JID, see XEP-0045)
|
|
421
|
+ // as the endpoint ID in colibri. We require endpoint IDs to be 8 hex digits because
|
|
422
|
+ // in some cases they get serialized into a 32bit field.
|
|
423
|
+ if (this.authenticatedUser) {
|
|
424
|
+ // For authenticated users generate a random ID.
|
|
425
|
+ mucNickname = RandomUtil.randomHexString(8).toLowerCase();
|
425
|
426
|
} else if (!this.authenticatedUser) {
|
426
|
|
- // node of the anonymous JID is very long - here we trim it a bit
|
427
|
|
- mucNickname = mucNickname.substr(0, 8);
|
428
|
|
- }
|
|
427
|
+ // We try to use the first part of the node (which for anonymous users on prosody is a UUID) to match
|
|
428
|
+ // the previous behavior (and maybe make debugging easier).
|
|
429
|
+ mucNickname = Strophe.getNodeFromJid(this.connection.jid).substr(0, 8)
|
|
430
|
+ .toLowerCase();
|
429
|
431
|
|
430
|
|
- // Constant JIDs need some random part to be appended in order to be
|
431
|
|
- // able to join the MUC more than once.
|
432
|
|
- if (this.authenticatedUser || cfgNickname !== null) {
|
433
|
|
- mucNickname += `-${RandomUtil.randomHexString(6)}`;
|
|
432
|
+ // But if this doesn't have the required format we just generate a new random nickname.
|
|
433
|
+ const re = /[0-9a-f]{8}/g;
|
|
434
|
+
|
|
435
|
+ if (!re.test(mucNickname)) {
|
|
436
|
+ mucNickname = RandomUtil.randomHexString(8).toLowerCase();
|
|
437
|
+ }
|
434
|
438
|
}
|
435
|
439
|
|
|
440
|
+ logger.info(`JID ${this.connection.jid} using MUC nickname $mucNickname`);
|
436
|
441
|
roomjid += mucNickname;
|
437
|
442
|
|
438
|
443
|
return this.connection.emuc.createRoom(roomjid, null, options);
|