Skip to content

Commit

Permalink
Merge pull request #31 from Dunedan/make-muc-room-options-configurable
Browse files Browse the repository at this point in the history
Make MUC room options configurable
  • Loading branch information
Dunedan authored Sep 13, 2024
2 parents d68f3e4 + 6ea3124 commit bdae5d0
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: {
"[email protected]": "0 A.D. Multiplayer Lobby",
"[email protected]": "Room for moderators"
"[email protected]": {
"description": "0 A.D. Multiplayer Lobby"
},
"[email protected]": {
"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 bdae5d0

Please sign in to comment.