Skip to content

Commit

Permalink
Make MUC room options configurable
Browse files Browse the repository at this point in the history
This adds support for configuring MUC room options via the
configuration file.
  • Loading branch information
Dunedan committed Aug 19, 2024
1 parent d68f3e4 commit 6ea3124
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
8 changes: 6 additions & 2 deletions config-lobby-vagrant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ ejabberd_muc_admins: [
# item is the JID of the MUC room and the value is used as room
# description.
ejabberd_lobby_muc_rooms: {
"arena@conference.localhost": "0 A.D. Multiplayer Lobby",
"moderation@conference.localhost": "Room for moderators"
"arena@conference.localhost": {
"description": "0 A.D. Multiplayer Lobby"
},
"moderation@conference.localhost": {
"description": "Room for moderators"
}
}
32 changes: 27 additions & 5 deletions roles/ejabberd/tasks/lobby_muc_room.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,39 @@
ansible.builtin.command: "ejabberdctl create_room {{ room.key | split('@') | first }}
{{ room.key | split('@') | last }}
{{ room.key | split('@') | last | regex_replace('^conference\\.(.*)$', '\\1') }}"
changed_when: true
when: room_exists.rc == 1

- name: Get room title
ansible.builtin.shell: # noqa: risky-shell-pipe
cmd: "ejabberdctl get_room_options {{ room.key | split('@') | first }}
{{ room.key | split('@') | last }} | grep -Ex 'title\\s+{{ room.key | split('@') | first }}'"
changed_when: false
failed_when: false
register: room_title

- name: Set room title
ansible.builtin.command: "ejabberdctl change_room_option {{ room.key | split('@') | first }}
{{ room.key | split('@') | last }} title {{ room.key | split('@') | first }}"
when: room_exists.rc == 1
when: room_title.rc == 1
changed_when: true

- name: Get room option
ansible.builtin.shell: # noqa: risky-shell-pipe
cmd: "ejabberdctl get_room_options {{ room.key | split('@') | first }}
{{ room.key | split('@') | last }} | grep -Ex '{{ option.key }}\\s+{{ option.value }}'"
changed_when: false
failed_when: false
loop: "{{ room.value | dict2items }}"
loop_control:
loop_var: option
register: room_options

- name: Set room description
- name: Set room option
ansible.builtin.command: "ejabberdctl change_room_option {{ room.key | split('@') | first }}
{{ room.key | split('@') | last }} description '{{ room.value }}'"
when: room_exists.rc == 1
changed_when: false
{{ room.key | split('@') | last }} {{ option.key }} '{{ room.value[option.key] }}'"
loop: >
{{ room_options.results | selectattr('rc', 'equalto', 1) | map(attribute='option') }}
loop_control:
loop_var: option
changed_when: true

0 comments on commit 6ea3124

Please sign in to comment.