Get Quay notification support working in the notification methods

This commit is contained in:
Joseph Schorr 2014-07-18 14:12:20 -04:00
parent 3865e3b1b7
commit f7c154abb5
4 changed files with 44 additions and 9 deletions

View file

@ -57,13 +57,33 @@ class QuayNotificationMethod(NotificationMethod):
# Probably deleted. # Probably deleted.
return True return True
target_name = config_data['target']; # Lookup the target user or team to which we'll send the notification.
target = model.get_user(target_name) target_info = config_data['target']
if not target: target_users = []
return False
model.create_notification(event_handler.event_name(), target, if target_info['kind'] == 'user':
metadata=notification_data['event_data']) 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 return True

View file

@ -347,6 +347,7 @@ def populate_database():
(1, [(1, [], 'v5.0'), (1, [], 'v6.0')], None)], (1, [(1, [], 'v5.0'), (1, [], 'v6.0')], None)],
None)) None))
"""
__generate_repository(new_user_1, 'insane', None, False, [], __generate_repository(new_user_1, 'insane', None, False, [],
(2, [(3, [], 'v2.0'), (2, [(3, [], 'v2.0'),
(1, [(1, [(1, [], ['latest', 'prod'])], (1, [(1, [(1, [], ['latest', 'prod'])],
@ -384,7 +385,8 @@ def populate_database():
(5, [], 'v4.20'), (5, [], 'v4.20'),
(1, [(1, [], 'v5.0'), (1, [], 'v6.0')], None)], (1, [(1, [], 'v5.0'), (1, [], 'v6.0')], None)],
None)) None))
"""
__generate_repository(new_user_2, 'publicrepo', __generate_repository(new_user_2, 'publicrepo',
'Public repository pullable by the world.', True, 'Public repository pullable by the world.', True,
[], (10, [], 'latest')) [], (10, [], 'latest'))

View file

@ -34,7 +34,7 @@
</span> </span>
</div> </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 on="methodInfo.id">
<span ng-switch-when="email"> <span ng-switch-when="email">
<span class="flow-text">To</span> <span class="flow-text">To</span>
@ -45,6 +45,11 @@
<span class="flow-text">To</span> <span class="flow-text">To</span>
<code>{{ config.url }}</code> <code>{{ config.url }}</code>
</span> </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> </span>
</div> </div>
</div> </div>

View file

@ -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} ' + 'message': 'We will be down for schedule maintenance from {from_date} to {to_date} ' +
'for {reason}. We are sorry about any inconvenience.', 'for {reason}. We are sorry about any inconvenience.',
'page': 'http://status.quay.io/' '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() { ApiService.testRepoNotification(null, params).then(function() {
bootbox.dialog({ 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": { "buttons": {
"close": { "close": {
"label": "Close", "label": "Close",