muc-views: don't assume we already have the occcupant

This commit is contained in:
JC Brand 2020-04-07 13:07:16 +02:00
parent 8c5e4b95d0
commit 9a6d6ddd1f

View File

@ -1417,12 +1417,12 @@ converse.plugins.add('converse-muc-views', {
if (!roles.length) {
return true;
}
if (!occupant) {
occupant = this.model.occupants.findWhere({'jid': _converse.bare_jid});
}
const role = occupant.get('role');
if (roles.includes(role)) {
return true;
occupant = occupant || this.model.occupants.findWhere({'jid': _converse.bare_jid});
if (occupant) {
const role = occupant.get('role');
if (roles.includes(role)) {
return true;
}
}
if (show_error) {
this.showErrorMessage(__('Forbidden: you do not have the necessary role in order to do that.'))
@ -1437,12 +1437,12 @@ converse.plugins.add('converse-muc-views', {
if (!affiliations.length) {
return true;
}
if (!occupant) {
occupant = this.model.occupants.findWhere({'jid': _converse.bare_jid});
}
const a = occupant.get('affiliation');
if (affiliations.includes(a)) {
return true;
occupant = occupant || this.model.occupants.findWhere({'jid': _converse.bare_jid});
if (occupant) {
const a = occupant.get('affiliation');
if (affiliations.includes(a)) {
return true;
}
}
if (show_error) {
this.showErrorMessage(__('Forbidden: you do not have the necessary affiliation in order to do that.'))