mirror of
https://github.com/ansible/awx.git
synced 2026-03-22 19:35:02 -02:30
Adds ability to send slack notification to a thread, updates tooltip in ui, and adds test button to notification details view
This commit is contained in:
@@ -36,10 +36,17 @@ class SlackBackend(AWXBaseEmailBackend, CustomNotificationBase):
|
||||
for r in m.recipients():
|
||||
if r.startswith('#'):
|
||||
r = r[1:]
|
||||
thread = None
|
||||
channel = r
|
||||
thread = None
|
||||
if ',' in r:
|
||||
channel, thread = r.split(',')
|
||||
if self.color:
|
||||
response = client.chat_postMessage(channel=r, as_user=True, attachments=[{"color": self.color, "text": m.subject}])
|
||||
response = client.chat_postMessage(
|
||||
channel=channel, thread_ts=thread, as_user=True, attachments=[{"color": self.color, "text": m.subject}]
|
||||
)
|
||||
else:
|
||||
response = client.chat_postMessage(channel=r, as_user=True, text=m.subject)
|
||||
response = client.chat_postMessage(channel=channel, thread_ts=thread, as_user=True, text=m.subject)
|
||||
logger.debug(response)
|
||||
if response['ok']:
|
||||
sent_messages += 1
|
||||
|
||||
@@ -24,7 +24,7 @@ def test_send_messages():
|
||||
message,
|
||||
]
|
||||
)
|
||||
WebClient_mock.chat_postMessage.assert_called_once_with(channel='random', as_user=True, text='test subject')
|
||||
WebClient_mock.chat_postMessage.assert_called_once_with(channel='random', thread_ts=None, as_user=True, text='test subject')
|
||||
assert sent_messages == 1
|
||||
|
||||
|
||||
@@ -47,7 +47,9 @@ def test_send_messages_with_color():
|
||||
]
|
||||
)
|
||||
|
||||
WebClient_mock.chat_postMessage.assert_called_once_with(channel='random', as_user=True, attachments=[{'color': '#006699', 'text': 'test subject'}])
|
||||
WebClient_mock.chat_postMessage.assert_called_once_with(
|
||||
channel='random', as_user=True, thread_ts=None, attachments=[{'color': '#006699', 'text': 'test subject'}]
|
||||
)
|
||||
assert sent_messages == 1
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user