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
|
||||
|
||||
|
||||
|
|
|
@ -347,6 +347,7 @@ def populate_database():
|
|||
(1, [(1, [], 'v5.0'), (1, [], 'v6.0')], None)],
|
||||
None))
|
||||
|
||||
"""
|
||||
__generate_repository(new_user_1, 'insane', None, False, [],
|
||||
(2, [(3, [], 'v2.0'),
|
||||
(1, [(1, [(1, [], ['latest', 'prod'])],
|
||||
|
@ -384,7 +385,8 @@ def populate_database():
|
|||
(5, [], 'v4.20'),
|
||||
(1, [(1, [], 'v5.0'), (1, [], 'v6.0')], None)],
|
||||
None))
|
||||
|
||||
"""
|
||||
|
||||
__generate_repository(new_user_2, 'publicrepo',
|
||||
'Public repository pullable by the world.', True,
|
||||
[], (10, [], 'latest'))
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
</span>
|
||||
</div>
|
||||
|
||||
<div class="view-row" ng-if="methodInfo.id == 'email' || methodInfo.id == 'webhook'">
|
||||
<div class="view-row">
|
||||
<span ng-switch on="methodInfo.id">
|
||||
<span ng-switch-when="email">
|
||||
<span class="flow-text">To</span>
|
||||
|
@ -45,6 +45,11 @@
|
|||
<span class="flow-text">To</span>
|
||||
<code>{{ config.url }}</code>
|
||||
</span>
|
||||
|
||||
<span ng-switch-when="quay_notification">
|
||||
<span class="flow-text">To</span>
|
||||
<span class="entity-reference" entity="config.target" namespace="repository.namespace"></span>
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1110,6 +1110,13 @@ quayApp = angular.module('quay', quayDependencies, function($provide, cfpLoading
|
|||
'message': 'We will be down for schedule maintenance from {from_date} to {to_date} ' +
|
||||
'for {reason}. We are sorry about any inconvenience.',
|
||||
'page': 'http://status.quay.io/'
|
||||
},
|
||||
'repo_push': {
|
||||
'level': 'info',
|
||||
'message': 'Repository {repository} has been pushed with the following tags updated: {updated_tags}',
|
||||
'page': function(metadata) {
|
||||
return '/repository/' + metadata.repository;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -4668,7 +4675,8 @@ quayApp.directive('externalNotificationView', function () {
|
|||
|
||||
ApiService.testRepoNotification(null, params).then(function() {
|
||||
bootbox.dialog({
|
||||
"message": "Test Notification Sent",
|
||||
"title": "Test Notification Queued",
|
||||
"message": "A test version of this notification has been queued and should appear shortly",
|
||||
"buttons": {
|
||||
"close": {
|
||||
"label": "Close",
|
||||
|
|
Reference in a new issue