Show policy violation errors to the user and make them ephemeral
Also, remove ephemeral messages after 10 seconds, not 20
This commit is contained in:
parent
3cc1b40aad
commit
599f7596f6
@ -1666,10 +1666,6 @@ converse.plugins.add('converse-muc-views', {
|
||||
} else if (!_.isNull(error.querySelector('forbidden'))) {
|
||||
this.showDisconnectMessages(__('You have been banned from this groupchat.'));
|
||||
}
|
||||
} else if (error.getAttribute('type') === 'modify') {
|
||||
if (!_.isNull(error.querySelector('jid-malformed'))) {
|
||||
this.showDisconnectMessages(__('No nickname was specified.'));
|
||||
}
|
||||
} else if (error.getAttribute('type') === 'cancel') {
|
||||
if (!_.isNull(error.querySelector('not-allowed'))) {
|
||||
this.showDisconnectMessages(__('You are not allowed to create new groupchats.'));
|
||||
|
@ -94,14 +94,14 @@ converse.plugins.add('converse-chatboxes', {
|
||||
if (this.get('file')) {
|
||||
this.on('change:put', this.uploadFile, this);
|
||||
}
|
||||
if (this.isOnlyChatStateNotification()) {
|
||||
if (this.isEphemeral()) {
|
||||
window.setTimeout(() => {
|
||||
try {
|
||||
this.destroy()
|
||||
} catch (e) {
|
||||
_converse.log(e, Strophe.LogLevel.ERROR);
|
||||
}
|
||||
}, 20000);
|
||||
}, 10000);
|
||||
}
|
||||
},
|
||||
|
||||
@ -150,6 +150,10 @@ converse.plugins.add('converse-chatboxes', {
|
||||
return u.isOnlyChatStateNotification(this);
|
||||
},
|
||||
|
||||
isEphemeral () {
|
||||
return this.isOnlyChatStateNotification() || this.get('type') === 'error';
|
||||
},
|
||||
|
||||
getDisplayName () {
|
||||
if (this.get('type') === 'groupchat') {
|
||||
return this.get('nick');
|
||||
|
@ -1353,6 +1353,19 @@ converse.plugins.add('converse-muc', {
|
||||
_converse.api.trigger('message', {'stanza': original_stanza, 'chatbox': this});
|
||||
},
|
||||
|
||||
|
||||
handleModifyError(pres) {
|
||||
const text = _.get(pres.querySelector('error text'), 'textContent');
|
||||
if (text) {
|
||||
const attrs = {
|
||||
'type': 'error',
|
||||
'message': text
|
||||
}
|
||||
this.messages.create(attrs);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
onErrorPresence (pres) {
|
||||
// TODO: currently showErrorMessageFromPresence handles
|
||||
// 'error" presences in converse-muc-views.
|
||||
@ -1360,6 +1373,8 @@ converse.plugins.add('converse-muc', {
|
||||
// handler removed from there.
|
||||
if (sizzle(`error not-authorized[xmlns="${Strophe.NS.STANZAS}"]`, pres).length) {
|
||||
this.save('connection_status', converse.ROOMSTATUS.PASSWORD_REQUIRED);
|
||||
} else if (sizzle(`error[type="modify"]`, pres).length) {
|
||||
this.handleModifyError(pres);
|
||||
} else {
|
||||
this.save('connection_status', converse.ROOMSTATUS.DISCONNECTED);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user