- 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:
Joseph Schorr 2014-07-31 13:30:54 -04:00
parent 1c7d72914b
commit 49801bc2c4
11 changed files with 37 additions and 56 deletions

View file

@ -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))