Commit 5d64f4c7 authored by JC Brand's avatar JC Brand

Newly generated build

parent c25cc4c7
...@@ -76507,13 +76507,39 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -76507,13 +76507,39 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return _converse.connection.sendIQ(iq, onSuccess, onError); return _converse.connection.sendIQ(iq, onSuccess, onError);
}, },
verifyRoles(roles) {
const me = this.model.occupants.findWhere({
'jid': _converse.bare_jid
});
if (!_.includes(roles, me.get('role'))) {
this.showErrorMessage(__(`Forbidden: you do not have the necessary role in order to do that.`));
return false;
}
return true;
},
verifyAffiliations(affiliations) {
const me = this.model.occupants.findWhere({
'jid': _converse.bare_jid
});
if (!_.includes(affiliations, me.get('affiliation'))) {
this.showErrorMessage(__(`Forbidden: you do not have the necessary affiliation in order to do that.`));
return false;
}
return true;
},
validateRoleChangeCommand(command, args) { validateRoleChangeCommand(command, args) {
/* Check that a command to change a groupchat user's role or /* Check that a command to change a groupchat user's role or
* affiliation has anough arguments. * affiliation has anough arguments.
*/ */
// TODO check if first argument is valid // TODO check if first argument is valid
if (args.length < 1 || args.length > 2) { if (args.length < 1 || args.length > 2) {
this.showErrorMessage(__('Error: the "%1$s" command takes two arguments, the user\'s nickname and optionally a reason.', command), true); this.showErrorMessage(__('Error: the "%1$s" command takes two arguments, the user\'s nickname and optionally a reason.', command));
return false; return false;
} }
...@@ -76523,7 +76549,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -76523,7 +76549,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
onCommandError(err) { onCommandError(err) {
_converse.log(err, Strophe.LogLevel.FATAL); _converse.log(err, Strophe.LogLevel.FATAL);
this.showErrorMessage(__("Sorry, an error happened while running the command. Check your browser's developer console for details."), true); this.showErrorMessage(__("Sorry, an error happened while running the command. Check your browser's developer console for details."));
}, },
parseMessageForCommands(text) { parseMessageForCommands(text) {
...@@ -76543,7 +76569,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -76543,7 +76569,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
switch (command) { switch (command) {
case 'admin': case 'admin':
if (!this.validateRoleChangeCommand(command, args)) { if (!this.verifyAffiliations(['owner']) || !this.validateRoleChangeCommand(command, args)) {
break; break;
} }
...@@ -76554,7 +76580,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -76554,7 +76580,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
break; break;
case 'ban': case 'ban':
if (!this.validateRoleChangeCommand(command, args)) { if (!this.verifyAffiliations(['owner', 'admin']) || !this.validateRoleChangeCommand(command, args)) {
break; break;
} }
...@@ -76565,7 +76591,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -76565,7 +76591,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
break; break;
case 'deop': case 'deop':
if (!this.validateRoleChangeCommand(command, args)) { if (!this.verifyAffiliations(['admin', 'owner']) || !this.validateRoleChangeCommand(command, args)) {
break; break;
} }
...@@ -76577,7 +76603,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -76577,7 +76603,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
break; break;
case 'kick': case 'kick':
if (!this.validateRoleChangeCommand(command, args)) { if (!this.verifyRoles(['moderator']) || !this.validateRoleChangeCommand(command, args)) {
break; break;
} }
...@@ -76585,7 +76611,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -76585,7 +76611,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
break; break;
case 'mute': case 'mute':
if (!this.validateRoleChangeCommand(command, args)) { if (!this.verifyRoles(['moderator']) || !this.validateRoleChangeCommand(command, args)) {
break; break;
} }
...@@ -76593,17 +76619,32 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -76593,17 +76619,32 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
break; break;
case 'member': case 'member':
if (!this.validateRoleChangeCommand(command, args)) { {
if (!this.verifyAffiliations(['admin', 'owner']) || !this.validateRoleChangeCommand(command, args)) {
break;
}
const occupant = this.model.occupants.findWhere({
'nick': args[0]
});
if (!occupant) {
this.showErrorMessage(__(`Error: Can't find a groupchat participant with the nickname "${args[0]}"`));
break; break;
} }
this.model.setAffiliation('member', [{ this.model.setAffiliation('member', [{
'jid': args[0], 'jid': occupant.get('jid'),
'reason': args[1] 'reason': args[1]
}]).then(() => this.model.occupants.fetchMembers(), err => this.onCommandError(err)); }]).then(() => this.model.occupants.fetchMembers(), err => this.onCommandError(err));
break; break;
}
case 'nick': case 'nick':
if (!this.verifyRoles(['visitor', 'participant', 'moderator'])) {
break;
}
_converse.connection.send($pres({ _converse.connection.send($pres({
from: _converse.connection.jid, from: _converse.connection.jid,
to: this.model.getRoomJIDAndNick(match[2]), to: this.model.getRoomJIDAndNick(match[2]),
...@@ -76613,7 +76654,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -76613,7 +76654,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
break; break;
case 'owner': case 'owner':
if (!this.validateRoleChangeCommand(command, args)) { if (!this.verifyAffiliations(['owner']) || !this.validateRoleChangeCommand(command, args)) {
break; break;
} }
...@@ -76624,7 +76665,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -76624,7 +76665,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
break; break;
case 'op': case 'op':
if (!this.validateRoleChangeCommand(command, args)) { if (!this.verifyAffiliations(['admin', 'owner']) || !this.validateRoleChangeCommand(command, args)) {
break; break;
} }
...@@ -76632,7 +76673,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -76632,7 +76673,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
break; break;
case 'revoke': case 'revoke':
if (!this.validateRoleChangeCommand(command, args)) { if (!this.verifyAffiliations(['admin', 'owner']) || !this.validateRoleChangeCommand(command, args)) {
break; break;
} }
...@@ -76655,7 +76696,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -76655,7 +76696,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
break; break;
case 'voice': case 'voice':
if (!this.validateRoleChangeCommand(command, args)) { if (!this.verifyRoles(['moderator']) || !this.validateRoleChangeCommand(command, args)) {
break; break;
} }
...@@ -77712,8 +77753,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -77712,8 +77753,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
$pres = _converse$env.$pres, $pres = _converse$env.$pres,
b64_sha1 = _converse$env.b64_sha1, b64_sha1 = _converse$env.b64_sha1,
sizzle = _converse$env.sizzle, sizzle = _converse$env.sizzle,
_ = _converse$env._, f = _converse$env.f,
moment = _converse$env.moment; // Add Strophe Namespaces moment = _converse$env.moment,
_ = _converse$env._; // Add Strophe Namespaces
Strophe.addNamespace('MUC_ADMIN', Strophe.NS.MUC + "#admin"); Strophe.addNamespace('MUC_ADMIN', Strophe.NS.MUC + "#admin");
Strophe.addNamespace('MUC_OWNER', Strophe.NS.MUC + "#owner"); Strophe.addNamespace('MUC_OWNER', Strophe.NS.MUC + "#owner");
...@@ -78202,7 +78244,6 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -78202,7 +78244,6 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* A promise which resolves once the list has been * A promise which resolves once the list has been
* retrieved. * retrieved.
*/ */
return new Promise((resolve, reject) => {
affiliation = affiliation || 'member'; affiliation = affiliation || 'member';
const iq = $iq({ const iq = $iq({
to: this.get('jid'), to: this.get('jid'),
...@@ -78212,9 +78253,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -78212,9 +78253,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}).c("item", { }).c("item", {
'affiliation': affiliation 'affiliation': affiliation
}); });
return _converse.api.sendIQ(iq);
_converse.connection.sendIQ(iq, resolve, reject);
});
}, },
setAffiliation(affiliation, members) { setAffiliation(affiliation, members) {
...@@ -78443,11 +78482,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -78443,11 +78482,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
affiliations = [affiliations]; affiliations = [affiliations];
} }
return new Promise((resolve, reject) => {
const promises = _.map(affiliations, _.partial(this.requestMemberList.bind(this))); const promises = _.map(affiliations, _.partial(this.requestMemberList.bind(this)));
Promise.all(promises).then(_.flow(u.marshallAffiliationIQs, resolve), _.flow(u.marshallAffiliationIQs, resolve)); return Promise.all(promises).then(iq => u.marshallAffiliationIQs(iq), iq => u.marshallAffiliationIQs(iq));
});
}, },
updateMemberLists(members, affiliations, deltaFunc) { updateMemberLists(members, affiliations, deltaFunc) {
...@@ -78834,27 +78871,15 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -78834,27 +78871,15 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}, },
fetchMembers() { fetchMembers() {
const old_jids = _.uniq(_.concat(_.map(this.where({ this.chatroom.getJidsWithAffiliations(['member', 'owner', 'admin']).then(new_members => {
'affiliation': 'admin' const new_jids = new_members.map(m => m.jid).filter(m => !_.isUndefined(m)),
}), item => item.get('jid')), _.map(this.where({ new_nicks = new_members.map(m => !m.jid && m.nick || undefined).filter(m => !_.isUndefined(m)),
'affiliation': 'member' removed_members = this.filter(m => {
}), item => item.get('jid')), _.map(this.where({ return f.includes(m.get('affiliation'), ['admin', 'member', 'owner']) && !f.includes(m.get('nick'), new_nicks) && !f.includes(m.get('jid'), new_jids);
'affiliation': 'owner'
}), item => item.get('jid'))));
this.chatroom.getJidsWithAffiliations(['member', 'owner', 'admin']).then(jids => {
_.each(_.difference(old_jids, jids), removed_jid => {
// Remove absent occupants who've been removed from
// the members lists.
if (removed_jid === _converse.bare_jid) {
return;
}
const occupant = this.findOccupant({
'jid': removed_jid
}); });
if (!occupant) { _.each(removed_members, occupant => {
if (occupant.get('jid') === _converse.bare_jid) {
return; return;
} }
...@@ -78863,10 +78888,18 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -78863,10 +78888,18 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
} }
}); });
_.each(jids, attrs => { _.each(new_members, attrs => {
const occupant = this.findOccupant({ let occupant;
if (attrs.jid) {
occupant = this.findOccupant({
'jid': attrs.jid 'jid': attrs.jid
}); });
} else {
occupant = this.findOccupant({
'nick': attrs.nick
});
}
if (occupant) { if (occupant) {
occupant.save(attrs); occupant.save(attrs);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment