mirror of
https://github.com/ZwareBear/awx.git
synced 2026-05-15 01:58:36 -05:00
Notification serializers, views, and tasks
* Implement concrete Notification model for notification runs * Implement NotificationTemplate and Notification serializers and views * Implement ancillary views * Implement NotificationTemplate trigger m2m fields on all job templates via a fields mixin * Link NotificationTemplates with an org * Link notifications with the activity stream * Implement Notification celery tasks * Extend Backend field parameters to identify sender and receiver as parameters needed by the message and not the backend itself * Updates to backends to better fit the django email backend model as it relates to Messages * Implement success job chain task + notifications * Implement notifications in error job chain task
This commit is contained in:
@@ -10,7 +10,10 @@ logger = logging.getLogger('awx.main.notifications.slack_backend')
|
||||
|
||||
class SlackBackend(BaseEmailBackend):
|
||||
|
||||
init_parameters = {"token": {"label": "Token", "type": "password"}}
|
||||
init_parameters = {"token": {"label": "Token", "type": "password"},
|
||||
"channels": {"label": "Destination Channels", "type": "list"}}
|
||||
recipient_parameter = "channels"
|
||||
sender_parameter = None
|
||||
|
||||
def __init__(self, token, fail_silently=False, **kwargs):
|
||||
super(SlackBackend, self).__init__(fail_silently=fail_silently)
|
||||
@@ -37,8 +40,9 @@ class SlackBackend(BaseEmailBackend):
|
||||
sent_messages = 0
|
||||
for m in messages:
|
||||
try:
|
||||
self.connection.rtm_send_message(m.to, m.body)
|
||||
sent_messages += 1
|
||||
for r in m.recipients():
|
||||
self.connection.rtm_send_message(r, m.body)
|
||||
sent_messages += 1
|
||||
except Exception as e:
|
||||
if not self.fail_silently:
|
||||
raise
|
||||
|
||||
Reference in New Issue
Block a user