-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix payload to match Rocket Chat 7.4.1 API #9882
base: main
Are you sure you want to change the base?
Changes from all commits
d9a6ef3
bdab72a
5e27b45
a1e8a46
ee2e635
3a32e46
539207d
33825b7
b620315
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
minor_changes: | ||
- rocketchat - parameter ``option_is_pre740`` has been added to control the format of the old payload (https://github.com/ansible-collections/community.general/pull/9882) | ||
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -100,6 +100,14 @@ | |||||
elements: dict | ||||||
description: | ||||||
- Define a list of attachments. | ||||||
is_pre740: | ||||||
description: | ||||||
- If V(true), the payload matches Rocket Chat prior to 7.4.0 format. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
- The default value of the parameter can be set to false in a few months' time. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
- This parameter will be removed in a future release when Rocket Chat 7.4.0 becomes the minimum supported version. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the official spelling is Rocket.Chat with a period:
Suggested change
(Also it might be that this has been already working with Rocket.Chat for a long time, and it was just that they dropped support for the old way in 7.4.0 - maybe because they thought that nobody is using it anymore since forever.) |
||||||
type: bool | ||||||
default: true | ||||||
version_added: 10.5.0 | ||||||
""" | ||||||
|
||||||
EXAMPLES = r""" | ||||||
|
@@ -165,7 +173,7 @@ | |||||
ROCKETCHAT_INCOMING_WEBHOOK = '%s://%s/hooks/%s' | ||||||
|
||||||
|
||||||
def build_payload_for_rocketchat(module, text, channel, username, icon_url, icon_emoji, link_names, color, attachments): | ||||||
def build_payload_for_rocketchat(module, text, channel, username, icon_url, icon_emoji, link_names, color, attachments, is_pre740): | ||||||
payload = {} | ||||||
if color == "normal" and text is not None: | ||||||
payload = dict(text=text) | ||||||
|
@@ -195,7 +203,9 @@ def build_payload_for_rocketchat(module, text, channel, username, icon_url, icon | |||||
attachment['fallback'] = attachment['text'] | ||||||
payload['attachments'].append(attachment) | ||||||
|
||||||
payload = "payload=" + module.jsonify(payload) | ||||||
payload = module.jsonify(payload) | ||||||
if is_pre740: | ||||||
payload = "payload=" + module.jsonify(payload) | ||||||
return payload | ||||||
|
||||||
|
||||||
|
@@ -225,7 +235,8 @@ def main(): | |||||
link_names=dict(type='int', default=1, choices=[0, 1]), | ||||||
validate_certs=dict(default=True, type='bool'), | ||||||
color=dict(type='str', default='normal', choices=['normal', 'good', 'warning', 'danger']), | ||||||
attachments=dict(type='list', elements='dict', required=False) | ||||||
attachments=dict(type='list', elements='dict', required=False), | ||||||
is_pre740=dict(default=True, type='bool') | ||||||
) | ||||||
) | ||||||
|
||||||
|
@@ -240,8 +251,9 @@ def main(): | |||||
link_names = module.params['link_names'] | ||||||
color = module.params['color'] | ||||||
attachments = module.params['attachments'] | ||||||
is_pre740 = module.params['is_pre740'] | ||||||
|
||||||
payload = build_payload_for_rocketchat(module, text, channel, username, icon_url, icon_emoji, link_names, color, attachments) | ||||||
payload = build_payload_for_rocketchat(module, text, channel, username, icon_url, icon_emoji, link_names, color, attachments, is_pre740) | ||||||
do_notify_rocketchat(module, domain, token, protocol, payload) | ||||||
|
||||||
module.exit_json(msg="OK") | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.