|
@@ -1281,30 +1281,33 @@ converse.plugins.add('converse-muc', {
|
|
_converse.api.trigger('message', {'stanza': original_stanza, 'chatbox': this});
|
|
_converse.api.trigger('message', {'stanza': original_stanza, 'chatbox': this});
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ onErrorPresence (pres) {
|
|
|
|
+ // TODO: currently showErrorMessageFromPresence handles
|
|
|
|
+ // 'error" presences in converse-muc-views.
|
|
|
|
+ // Instead, they should be handled here and the presence
|
|
|
|
+ // handler removed from there.
|
|
|
|
+ if (sizzle(`error not-authorized[xmlns="${Strophe.NS.STANZAS}"]`, pres).length) {
|
|
|
|
+ this.save('connection_status', converse.ROOMSTATUS.PASSWORD_REQUIRED);
|
|
|
|
+ } else {
|
|
|
|
+ this.save('connection_status', converse.ROOMSTATUS.DISCONNECTED);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Handles all MUC presence stanzas.
|
|
* Handles all MUC presence stanzas.
|
|
* @private
|
|
* @private
|
|
* @method _converse.ChatRoom#onPresence
|
|
* @method _converse.ChatRoom#onPresence
|
|
- * @param { XMLElement } pres - The stanza
|
|
|
|
|
|
+ * @param { XMLElement } stanza
|
|
*/
|
|
*/
|
|
- onPresence (pres) {
|
|
|
|
- if (pres.getAttribute('type') === 'error') {
|
|
|
|
- // TODO: currently showErrorMessageFromPresence handles
|
|
|
|
- // 'error" presences in converse-muc-views.
|
|
|
|
- // Instead, they should be handled here and the presence
|
|
|
|
- // handler removed from there.
|
|
|
|
- if (sizzle(`error not-authorized[xmlns="${Strophe.NS.STANZAS}"]`, pres).length) {
|
|
|
|
- this.save('connection_status', converse.ROOMSTATUS.PASSWORD_REQUIRED);
|
|
|
|
- } else {
|
|
|
|
- this.save('connection_status', converse.ROOMSTATUS.DISCONNECTED);
|
|
|
|
- }
|
|
|
|
- return;
|
|
|
|
|
|
+ onPresence (stanza) {
|
|
|
|
+ if (stanza.getAttribute('type') === 'error') {
|
|
|
|
+ return this.onErrorPresence(stanza);
|
|
}
|
|
}
|
|
- const is_self = pres.querySelector("status[code='110']");
|
|
|
|
- if (is_self && pres.getAttribute('type') !== 'unavailable') {
|
|
|
|
- this.onOwnPresence(pres);
|
|
|
|
|
|
+ if (stanza.querySelector("status[code='110']")) {
|
|
|
|
+ this.onOwnPresence(stanza);
|
|
}
|
|
}
|
|
- this.updateOccupantsOnPresence(pres);
|
|
|
|
|
|
+ this.updateOccupantsOnPresence(stanza);
|
|
|
|
+
|
|
if (this.get('role') !== 'none' && this.get('connection_status') === converse.ROOMSTATUS.CONNECTING) {
|
|
if (this.get('role') !== 'none' && this.get('connection_status') === converse.ROOMSTATUS.CONNECTING) {
|
|
this.save('connection_status', converse.ROOMSTATUS.CONNECTED);
|
|
this.save('connection_status', converse.ROOMSTATUS.CONNECTED);
|
|
}
|
|
}
|
|
@@ -1325,41 +1328,45 @@ converse.plugins.add('converse-muc', {
|
|
* @method _converse.ChatRoom#onOwnPresence
|
|
* @method _converse.ChatRoom#onOwnPresence
|
|
* @param { XMLElement } pres - The stanza
|
|
* @param { XMLElement } pres - The stanza
|
|
*/
|
|
*/
|
|
- onOwnPresence (pres) {
|
|
|
|
- this.saveAffiliationAndRole(pres);
|
|
|
|
-
|
|
|
|
- const locked_room = pres.querySelector("status[code='201']");
|
|
|
|
- if (locked_room) {
|
|
|
|
- if (this.get('auto_configure')) {
|
|
|
|
- this.autoConfigureChatRoom().then(() => this.refreshRoomFeatures());
|
|
|
|
- } else if (_converse.muc_instant_rooms) {
|
|
|
|
- // Accept default configuration
|
|
|
|
- this.saveConfiguration().then(() => this.refreshRoomFeatures());
|
|
|
|
- } else {
|
|
|
|
- /**
|
|
|
|
- * Triggered when a new room has been created which first needs to be configured
|
|
|
|
- * and when `auto_configure` is set to `false`.
|
|
|
|
- * Used by `_converse.ChatRoomView` in order to know when to render the
|
|
|
|
- * configuration form for a new room.
|
|
|
|
- * @event _converse.ChatRoom#configurationNeeded
|
|
|
|
- * @example _converse.api.listen.on('configurationNeeded', () => { ... });
|
|
|
|
- */
|
|
|
|
- this.trigger('configurationNeeded');
|
|
|
|
- return; // We haven't yet entered the groupchat, so bail here.
|
|
|
|
- }
|
|
|
|
- } else if (!this.features.get('fetched')) {
|
|
|
|
- // The features for this groupchat weren't fetched.
|
|
|
|
- // That must mean it's a new groupchat without locking
|
|
|
|
- // (in which case Prosody doesn't send a 201 status),
|
|
|
|
- // otherwise the features would have been fetched in
|
|
|
|
- // the "initialize" method already.
|
|
|
|
- if (this.get('affiliation') === 'owner' && this.get('auto_configure')) {
|
|
|
|
- this.autoConfigureChatRoom().then(() => this.refreshRoomFeatures());
|
|
|
|
- } else {
|
|
|
|
- this.getRoomFeatures();
|
|
|
|
|
|
+ onOwnPresence (stanza) {
|
|
|
|
+ this.saveAffiliationAndRole(stanza);
|
|
|
|
+
|
|
|
|
+ if (stanza.getAttribute('type') === 'unavailable') {
|
|
|
|
+ this.save('connection_status', converse.ROOMSTATUS.DISCONNECTED);
|
|
|
|
+ } else {
|
|
|
|
+ const locked_room = stanza.querySelector("status[code='201']");
|
|
|
|
+ if (locked_room) {
|
|
|
|
+ if (this.get('auto_configure')) {
|
|
|
|
+ this.autoConfigureChatRoom().then(() => this.refreshRoomFeatures());
|
|
|
|
+ } else if (_converse.muc_instant_rooms) {
|
|
|
|
+ // Accept default configuration
|
|
|
|
+ this.saveConfiguration().then(() => this.refreshRoomFeatures());
|
|
|
|
+ } else {
|
|
|
|
+ /**
|
|
|
|
+ * Triggered when a new room has been created which first needs to be configured
|
|
|
|
+ * and when `auto_configure` is set to `false`.
|
|
|
|
+ * Used by `_converse.ChatRoomView` in order to know when to render the
|
|
|
|
+ * configuration form for a new room.
|
|
|
|
+ * @event _converse.ChatRoom#configurationNeeded
|
|
|
|
+ * @example _converse.api.listen.on('configurationNeeded', () => { ... });
|
|
|
|
+ */
|
|
|
|
+ this.trigger('configurationNeeded');
|
|
|
|
+ return; // We haven't yet entered the groupchat, so bail here.
|
|
|
|
+ }
|
|
|
|
+ } else if (!this.features.get('fetched')) {
|
|
|
|
+ // The features for this groupchat weren't fetched.
|
|
|
|
+ // That must mean it's a new groupchat without locking
|
|
|
|
+ // (in which case Prosody doesn't send a 201 status),
|
|
|
|
+ // otherwise the features would have been fetched in
|
|
|
|
+ // the "initialize" method already.
|
|
|
|
+ if (this.get('affiliation') === 'owner' && this.get('auto_configure')) {
|
|
|
|
+ this.autoConfigureChatRoom().then(() => this.refreshRoomFeatures());
|
|
|
|
+ } else {
|
|
|
|
+ this.getRoomFeatures();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ this.save('connection_status', converse.ROOMSTATUS.ENTERED);
|
|
}
|
|
}
|
|
- this.save('connection_status', converse.ROOMSTATUS.ENTERED);
|
|
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|