Fix the spawn_notification to work in all cases and clean up some of the remaining code
This commit is contained in:
parent
591cd020b8
commit
752efb9e0f
17 changed files with 18379 additions and 18415 deletions
|
@ -17,6 +17,7 @@ from werkzeug.routing import BaseConverter
|
|||
from functools import wraps
|
||||
from config import getFrontendVisibleConfig
|
||||
from external_libraries import get_external_javascript, get_external_css
|
||||
from endpoints.notificationhelper import spawn_notification
|
||||
|
||||
import features
|
||||
|
||||
|
@ -231,41 +232,15 @@ def start_build(repository, dockerfile_id, tags, build_name, subdir, manual,
|
|||
'build_id': build_request.uuid,
|
||||
'build_name': build_name,
|
||||
'docker_tags': tags,
|
||||
'is_manual': manual,
|
||||
'trigger_id': trigger.uuid,
|
||||
'trigger_kind': trigger.service.name
|
||||
'is_manual': manual
|
||||
}
|
||||
|
||||
if trigger:
|
||||
event_data['trigger_id'] = trigger.uuid
|
||||
event_data['trigger_kind'] = trigger.service.name
|
||||
|
||||
spawn_notification(repository, 'build_queued', event_data,
|
||||
subpage='build?current=' % build_request.uuid,
|
||||
subpage='build?current=%s' % build_request.uuid,
|
||||
pathargs=['build', build_request.uuid])
|
||||
return build_request
|
||||
|
||||
|
||||
def spawn_notification(repository, event_name, extra_data={}, subpage=None, pathargs=[]):
|
||||
homepage = 'https://quay.io/repository/%s' % repo_string
|
||||
if subpage:
|
||||
homepage = homepage + subpage
|
||||
|
||||
repo_string = '%s/%s' % (repo.namespace, repo.name)
|
||||
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': repository.id,
|
||||
'event_data': event_data
|
||||
}
|
||||
|
||||
path = [namespace, repository, 'notification', event_name] + pathargs
|
||||
notification_queue.put(path, json.dumps(notification_data))
|
||||
|
|
|
@ -8,7 +8,7 @@ from collections import OrderedDict
|
|||
|
||||
from data import model
|
||||
from data.model import oauth
|
||||
from app import analytics, app, notification_queue, authentication, userevents, storage
|
||||
from app import analytics, app, authentication, userevents, storage
|
||||
from auth.auth import process_auth
|
||||
from auth.auth_context import get_authenticated_user, get_validated_token, get_validated_oauth_token
|
||||
from util.names import parse_repository_name
|
||||
|
@ -17,7 +17,7 @@ from auth.permissions import (ModifyRepositoryPermission, UserAdminPermission,
|
|||
ReadRepositoryPermission, CreateRepositoryPermission)
|
||||
|
||||
from util.http import abort
|
||||
from endpoints.common import spawn_notification
|
||||
from endpoints.notificationhelper import spawn_notification
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
32
endpoints/notificationhelper.py
Normal file
32
endpoints/notificationhelper.py
Normal file
|
@ -0,0 +1,32 @@
|
|||
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))
|
Reference in a new issue