mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-09-30 13:33:21 -07:00
Force Content-type header to application/json if is_pre740 is false (#10832)
Some checks failed
EOL CI / EOL Sanity (Ⓐ2.16) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.16+py2.7) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.16+py3.11) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.16+py3.6) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+alpine3+py:azp/posix/1/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+alpine3+py:azp/posix/2/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+alpine3+py:azp/posix/3/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+fedora38+py:azp/posix/1/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+fedora38+py:azp/posix/2/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+fedora38+py:azp/posix/3/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+opensuse15+py:azp/posix/1/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+opensuse15+py:azp/posix/2/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+opensuse15+py:azp/posix/3/) (push) Has been cancelled
nox / Run extra sanity tests (push) Has been cancelled
Some checks failed
EOL CI / EOL Sanity (Ⓐ2.16) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.16+py2.7) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.16+py3.11) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.16+py3.6) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+alpine3+py:azp/posix/1/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+alpine3+py:azp/posix/2/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+alpine3+py:azp/posix/3/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+fedora38+py:azp/posix/1/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+fedora38+py:azp/posix/2/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+fedora38+py:azp/posix/3/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+opensuse15+py:azp/posix/1/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+opensuse15+py:azp/posix/2/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.16+opensuse15+py:azp/posix/3/) (push) Has been cancelled
nox / Run extra sanity tests (push) Has been cancelled
* Force Content-type header to application/json if is_pre740 is false * Remove response variable from fail_json module * Add a missing blank line to match pep8 requirement * Add changelog fragment of issue #10796 * Rename fragment section * Improve fragment readability Co-authored-by: Felix Fontein <felix@fontein.de> --------- Co-authored-by: ludovic <ludovic.petetin@aleph-networks.com> Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
b865bf5751
commit
0f23b9e391
2 changed files with 8 additions and 3 deletions
|
@ -202,14 +202,17 @@ def build_payload_for_rocketchat(module, text, channel, username, icon_url, icon
|
|||
return payload
|
||||
|
||||
|
||||
def do_notify_rocketchat(module, domain, token, protocol, payload):
|
||||
def do_notify_rocketchat(module, domain, token, protocol, payload, is_pre740):
|
||||
|
||||
if token.count('/') < 1:
|
||||
module.fail_json(msg="Invalid Token specified, provide a valid token")
|
||||
|
||||
rocketchat_incoming_webhook = ROCKETCHAT_INCOMING_WEBHOOK % (protocol, domain, token)
|
||||
|
||||
response, info = fetch_url(module, rocketchat_incoming_webhook, data=payload)
|
||||
headers = None
|
||||
if not is_pre740:
|
||||
headers = {'Content-type': 'application/json'}
|
||||
response, info = fetch_url(module, rocketchat_incoming_webhook, data=payload, headers=headers)
|
||||
if info['status'] != 200:
|
||||
module.fail_json(msg="failed to send message, return status=%s" % str(info['status']))
|
||||
|
||||
|
@ -256,7 +259,7 @@ def main():
|
|||
is_pre740 = True
|
||||
|
||||
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)
|
||||
do_notify_rocketchat(module, domain, token, protocol, payload, is_pre740)
|
||||
|
||||
module.exit_json(msg="OK")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue