Commit dd082107 authored by supun19's avatar supun19 Committed by JC Brand

Groupchat auto-configuration now supports list-multi fields

parent 1d9e1a62
# Changelog # Changelog
## 5.0.0 (Unreleased) ## 5.0.0 (Unreleased)
- Groupchat default configuration now supports `list-multi` fields
- Bugfix: Don't set `muc_domain` for roomspanel if `locked_muc_domain` is `true`. - Bugfix: Don't set `muc_domain` for roomspanel if `locked_muc_domain` is `true`.
- Bugfix: Modal auto-closes when you open it for a second time. - Bugfix: Modal auto-closes when you open it for a second time.
- Take roster nickname into consideration when rendering messages and chat headings. - Take roster nickname into consideration when rendering messages and chat headings.
......
...@@ -156,6 +156,7 @@ ...@@ -156,6 +156,7 @@
'nick': 'some1', 'nick': 'some1',
'auto_configure': true, 'auto_configure': true,
'roomconfig': { 'roomconfig': {
'getmemberlist': ['moderator', 'participant'],
'changesubject': false, 'changesubject': false,
'membersonly': true, 'membersonly': true,
'persistentroom': true, 'persistentroom': true,
...@@ -224,6 +225,13 @@ ...@@ -224,6 +225,13 @@
<field type="list-single" var="muc#roomconfig_whois" label="Who May Discover Real JIDs?"><option label="Moderators Only"> <field type="list-single" var="muc#roomconfig_whois" label="Who May Discover Real JIDs?"><option label="Moderators Only">
<value>moderators</value></option><option label="Anyone"><value>anyone</value></option> <value>moderators</value></option><option label="Anyone"><value>anyone</value></option>
</field> </field>
<field label="Roles and Affiliations that May Retrieve Member List"
type="list-multi"
var="muc#roomconfig_getmemberlist">
<value>moderator</value>
<value>participant</value>
<value>visitor</value>
</field>
<field type="text-private" var="muc#roomconfig_roomsecret" label="Password"><value/></field> <field type="text-private" var="muc#roomconfig_roomsecret" label="Password"><value/></field>
<field type="boolean" var="muc#roomconfig_moderatedroom" label="Make Room Moderated?"/> <field type="boolean" var="muc#roomconfig_moderatedroom" label="Make Room Moderated?"/>
<field type="boolean" var="muc#roomconfig_membersonly" label="Make Room Members-Only?"/> <field type="boolean" var="muc#roomconfig_membersonly" label="Make Room Members-Only?"/>
...@@ -243,6 +251,7 @@ ...@@ -243,6 +251,7 @@
expect(sizzle('field[var="muc#roomconfig_roomname"] value', sent_stanza).pop().textContent).toBe('Room'); expect(sizzle('field[var="muc#roomconfig_roomname"] value', sent_stanza).pop().textContent).toBe('Room');
expect(sizzle('field[var="muc#roomconfig_roomdesc"] value', sent_stanza).pop().textContent).toBe('Welcome to this groupchat'); expect(sizzle('field[var="muc#roomconfig_roomdesc"] value', sent_stanza).pop().textContent).toBe('Welcome to this groupchat');
expect(sizzle('field[var="muc#roomconfig_persistentroom"] value', sent_stanza).pop().textContent).toBe('1'); expect(sizzle('field[var="muc#roomconfig_persistentroom"] value', sent_stanza).pop().textContent).toBe('1');
expect(sizzle('field[var="muc#roomconfig_getmemberlist"] value', sent_stanza).map(e => e.textContent).join(' ')).toBe('moderator participant');
expect(sizzle('field[var="muc#roomconfig_publicroom"] value ', sent_stanza).pop().textContent).toBe('1'); expect(sizzle('field[var="muc#roomconfig_publicroom"] value ', sent_stanza).pop().textContent).toBe('1');
expect(sizzle('field[var="muc#roomconfig_changesubject"] value', sent_stanza).pop().textContent).toBe('0'); expect(sizzle('field[var="muc#roomconfig_changesubject"] value', sent_stanza).pop().textContent).toBe('0');
expect(sizzle('field[var="muc#roomconfig_whois"] value ', sent_stanza).pop().textContent).toBe('anyone'); expect(sizzle('field[var="muc#roomconfig_whois"] value ', sent_stanza).pop().textContent).toBe('anyone');
......
...@@ -658,19 +658,18 @@ converse.plugins.add('converse-muc', { ...@@ -658,19 +658,18 @@ converse.plugins.add('converse-muc', {
const fieldname = field.getAttribute('var').replace('muc#roomconfig_', ''); const fieldname = field.getAttribute('var').replace('muc#roomconfig_', '');
const config = this.get('roomconfig'); const config = this.get('roomconfig');
if (fieldname in config) { if (fieldname in config) {
let value; let values;
switch (type) { switch (type) {
case 'boolean': case 'boolean':
value = config[fieldname] ? 1 : 0; values = [config[fieldname] ? 1 : 0];
break; break;
case 'list-multi': case 'list-multi':
// TODO: we don't yet handle "list-multi" types values = config[fieldname];
value = field.innerHTML;
break; break;
default: default:
value = config[fieldname]; values= [config[fieldname]];
} }
field.innerHTML = $build('value').t(value); field.innerHTML = values.map(v => $build('value').t(v)).join('');
} }
return field; return field;
}, },
......
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