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,12 +57,32 @@ 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':
|
||||||
|
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'])
|
metadata=notification_data['event_data'])
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -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,6 +385,7 @@ 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,
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -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",
|
||||||
|
|
Reference in a new issue