mattermost: add support for message priority (#9087)

* mattermost: add support for message priority

* Add changelog fragment

* Consistency nit in changelog

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>

* Validate priority arg and doc fixes

Validate the two possible priorities with choices.
Add priority arg to one example and add version_added
field for the arg docs.

* Update changelog.

---------

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
pull/9098/head
bluikko 2024-11-03 20:55:16 +07:00 committed by GitHub
parent 3d03c373ff
commit 94e3635c0a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View File

@ -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).

View File

@ -62,13 +62,19 @@ options:
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
@ -92,6 +98,7 @@ EXAMPLES = """
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:
@ -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'),
),
@ -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