diff --git a/endpoints/notificationhelper.py b/endpoints/notificationhelper.py index 66d7ac0dc..37e5bc56b 100644 --- a/endpoints/notificationhelper.py +++ b/endpoints/notificationhelper.py @@ -10,7 +10,7 @@ from auth.auth_context import get_authenticated_user, get_validated_oauth_token DEFAULT_BATCH_SIZE = 1000 -def build_event_data(repo, extra_data={}, subpage=None): +def build_event_data(repo, extra_data=None, subpage=None): repo_string = '%s/%s' % (repo.namespace_name, repo.name) homepage = '%s://%s/repository/%s' % (app.config['PREFERRED_URL_SCHEME'], app.config['SERVER_HOSTNAME'], @@ -30,7 +30,7 @@ def build_event_data(repo, extra_data={}, subpage=None): 'homepage': homepage, } - event_data.update(extra_data) + event_data.update(extra_data or {}) return event_data def build_notification_data(notification, event_data, performer_data=None): @@ -63,14 +63,14 @@ def notification_batch(batch_size=DEFAULT_BATCH_SIZE): the callable will be bulk inserted into the queue with the specified batch size. """ with notification_queue.batch_insert(batch_size) as queue_put: - def spawn_notification_batch(repo, event_name, extra_data={}, subpage=None, pathargs=[], + def spawn_notification_batch(repo, event_name, extra_data=None, subpage=None, pathargs=None, performer_data=None): event_data = build_event_data(repo, extra_data=extra_data, subpage=subpage) notifications = model.notification.list_repo_notifications(repo.namespace_name, repo.name, event_name=event_name) - path = [repo.namespace_name, repo.name, event_name] + pathargs + path = [repo.namespace_name, repo.name, event_name] + (pathargs or []) for notification in list(notifications): notification_data = build_notification_data(notification, event_data, performer_data) queue_put(path, json.dumps(notification_data)) @@ -78,7 +78,7 @@ def notification_batch(batch_size=DEFAULT_BATCH_SIZE): yield spawn_notification_batch -def spawn_notification(repo, event_name, extra_data={}, subpage=None, pathargs=[], +def spawn_notification(repo, event_name, extra_data=None, subpage=None, pathargs=None, performer_data=None): with notification_batch(1) as batch_spawn: batch_spawn(repo, event_name, extra_data, subpage, pathargs, performer_data)