- Add web hook queue code back in. We'll remove it and turn it off after this CL goes to prod
- Make notification lookup always be by repo and its UUID, rather than the internal DB ID - Add the init script for the notification worker
This commit is contained in:
parent
1c7d72914b
commit
49801bc2c4
11 changed files with 37 additions and 56 deletions
|
@ -8,6 +8,7 @@ from endpoints.api import (RepositoryParamResource, nickname, resource, require_
|
|||
from endpoints.notificationevent import NotificationEvent
|
||||
from endpoints.notificationmethod import (NotificationMethod,
|
||||
CannotValidateNotificationMethodException)
|
||||
from endpoints.notificationhelper import build_notification_data
|
||||
from data import model
|
||||
|
||||
|
||||
|
@ -134,11 +135,7 @@ class TestRepositoryNotification(RepositoryParamResource):
|
|||
|
||||
event_info = NotificationEvent.get_event(notification.event.name)
|
||||
sample_data = event_info.get_sample_data(repository=notification.repository)
|
||||
notification_data = {
|
||||
'notification_id': notification.id,
|
||||
'repository_id': notification.repository.id,
|
||||
'event_data': sample_data
|
||||
}
|
||||
notification_data = build_notification_data(notification, sample_data)
|
||||
notification_queue.put([namespace, repository, notification.event.name],
|
||||
json.dumps(notification_data))
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ class RepoPushEvent(NotificationEvent):
|
|||
Tags Updated: %s
|
||||
""" % (event_data['homepage'],
|
||||
event_data['repository'],
|
||||
event_data['updated_tags'])
|
||||
', '.join(event_data['updated_tags']))
|
||||
|
||||
return html
|
||||
|
||||
|
|
|
@ -27,17 +27,20 @@ def build_event_data(repo, extra_data={}, subpage=None):
|
|||
event_data.update(extra_data)
|
||||
return event_data
|
||||
|
||||
def build_notification_data(notification, event_data):
|
||||
return {
|
||||
'notification_uuid': notification.uuid,
|
||||
'repository_namespace': notification.repository.namespace,
|
||||
'repository_name': notification.repository.name,
|
||||
'event_data': event_data
|
||||
}
|
||||
|
||||
|
||||
def spawn_notification(repo, event_name, extra_data={}, subpage=None, pathargs=[]):
|
||||
event_data = build_event_data(repo, extra_data=extra_data, subpage=subpage)
|
||||
|
||||
notifications = model.list_repo_notifications(repo.namespace, repo.name, event_name=event_name)
|
||||
for notification in notifications:
|
||||
notification_data = {
|
||||
'notification_id': notification.id,
|
||||
'repository_id': repo.id,
|
||||
'event_data': event_data
|
||||
}
|
||||
|
||||
notification_data = build_notification_data(notification, event_data)
|
||||
path = [repo.namespace, repo.name, event_name] + pathargs
|
||||
notification_queue.put(path, json.dumps(notification_data))
|
||||
|
|
|
@ -100,8 +100,7 @@ class QuayNotificationMethod(NotificationMethod):
|
|||
|
||||
|
||||
def perform(self, notification, event_handler, notification_data):
|
||||
repository_id = notification_data['repository_id']
|
||||
repository = model.lookup_repository(repository_id)
|
||||
repository = notification.repository
|
||||
if not repository:
|
||||
# Probably deleted.
|
||||
return True
|
||||
|
|
Reference in a new issue