Get Quay notification support working in the notification methods
This commit is contained in:
parent
3865e3b1b7
commit
f7c154abb5
4 changed files with 44 additions and 9 deletions
|
@ -57,13 +57,33 @@ class QuayNotificationMethod(NotificationMethod):
|
|||
# Probably deleted.
|
||||
return True
|
||||
|
||||
target_name = config_data['target'];
|
||||
target = model.get_user(target_name)
|
||||
if not target:
|
||||
return False
|
||||
# Lookup the target user or team to which we'll send the notification.
|
||||
target_info = config_data['target']
|
||||
target_users = []
|
||||
|
||||
model.create_notification(event_handler.event_name(), target,
|
||||
metadata=notification_data['event_data'])
|
||||
if target_info['kind'] == 'user':
|
||||
target = model.get_user(target_info['name'])
|
||||
if not target:
|
||||
# Just to be safe.
|
||||
return True
|
||||
|
||||
target_users.append(target)
|
||||
elif target_info['kind'] == 'team':
|
||||
# Lookup the team.
|
||||
team = None
|
||||
try:
|
||||
team = model.get_organization_team(repository.namespace, target_info['name'])
|
||||
except model.InvalidTeamException:
|
||||
# Probably deleted.
|
||||
return True
|
||||
|
||||
# Lookup the team's members
|
||||
target_users = model.get_organization_team_members(team.id)
|
||||
|
||||
# For each of the target users, create a notification.
|
||||
for target_user in set(target_users):
|
||||
model.create_notification(event_handler.event_name(), target_user,
|
||||
metadata=notification_data['event_data'])
|
||||
return True
|
||||
|
||||
|
||||
|
|
Reference in a new issue