Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mattermost: add support for message priority #9087

Merged
merged 5 commits into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/9087-mattermost-priority.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- mattermost - adds support for message priority (https://github.com/ansible-collections/community.general/issues/9068, https://github.com/ansible-collections/community.general/pull/9087).
12 changes: 11 additions & 1 deletion plugins/modules/mattermost.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,19 @@
username:
type: str
description:
- This is the sender of the message (Username Override need to be enabled by mattermost admin, see mattermost doc.
- This is the sender of the message (Username Override need to be enabled by mattermost admin, see mattermost doc).
default: Ansible
icon_url:
type: str
description:
- URL for the message sender's icon.
default: https://docs.ansible.com/favicon.ico
priority:
type: str
description:
- Set a priority for the message.
choices: [ important, urgent ]
version_added: 10.0.0
validate_certs:
description:
- If V(false), SSL certificates will not be validated. This should only be used
Expand All @@ -92,6 +98,7 @@
channel: notifications
username: 'Ansible on {{ inventory_hostname }}'
icon_url: http://www.example.com/some-image-file.png
priority: important

- name: Send attachments message via Mattermost
community.general.mattermost:
Expand Down Expand Up @@ -135,6 +142,7 @@ def main():
channel=dict(type='str', default=None),
username=dict(type='str', default='Ansible'),
icon_url=dict(type='str', default='https://docs.ansible.com/favicon.ico'),
priority=dict(type='str', default=None, choices=['important', 'urgent']),
validate_certs=dict(default=True, type='bool'),
attachments=dict(type='list', elements='dict'),
),
Expand All @@ -154,6 +162,8 @@ def main():
for param in ['text', 'channel', 'username', 'icon_url', 'attachments']:
if module.params[param] is not None:
payload[param] = module.params[param]
if module.params['priority'] is not None:
payload['priority'] = {'priority': module.params['priority']}

payload = module.jsonify(payload)
result['payload'] = payload
Expand Down