from app import app, notification_queue from data import model import json def spawn_notification(repo, event_name, extra_data={}, subpage=None, pathargs=[]): repo_string = '%s/%s' % (repo.namespace, repo.name) homepage = 'https://quay.io/repository/%s' % repo_string if subpage: homepage = homepage + subpage event_data = { 'repository': repo_string, 'namespace': repo.namespace, 'name': repo.name, 'docker_url': 'quay.io/%s' % repo_string, 'homepage': homepage, 'visibility': repo.visibility.name } event_data.update(extra_data) 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 } path = [repo.namespace, repo.name, 'notification', event_name] + pathargs notification_queue.put(path, json.dumps(notification_data))