diff --git a/lib/galaxy/webapps/galaxy/services/histories.py b/lib/galaxy/webapps/galaxy/services/histories.py index dbd14f7d271..d5a6a75ffba 100644 --- a/lib/galaxy/webapps/galaxy/services/histories.py +++ b/lib/galaxy/webapps/galaxy/services/histories.py @@ -40,7 +40,6 @@ from galaxy.managers.histories import ( HistoryManager, HistorySerializer, ) -from galaxy.managers.notification import NotificationManager from galaxy.managers.users import UserManager from galaxy.model import HistoryDatasetAssociation from galaxy.model.base import transaction @@ -89,6 +88,7 @@ from galaxy.webapps.galaxy.services.base import ( ServesExportStores, ServiceBase, ) +from galaxy.webapps.galaxy.services.notifications import NotificationService from galaxy.webapps.galaxy.services.sharable import ShareableService log = logging.getLogger(__name__) @@ -121,7 +121,7 @@ class HistoriesService(ServiceBase, ConsumesModelStores, ServesExportStores): history_export_manager: HistoryExportManager, filters: HistoryFilters, short_term_storage_allocator: ShortTermStorageAllocator, - notification_manager: NotificationManager, + notification_service: NotificationService, ): super().__init__(security) self.manager = manager @@ -131,7 +131,7 @@ class HistoriesService(ServiceBase, ConsumesModelStores, ServesExportStores): self.citations_manager = citations_manager self.history_export_manager = history_export_manager self.filters = filters - self.shareable_service = ShareableHistoryService(self.manager, self.serializer, notification_manager) + self.shareable_service = ShareableHistoryService(self.manager, self.serializer, notification_service) self.short_term_storage_allocator = short_term_storage_allocator def index( diff --git a/lib/galaxy/webapps/galaxy/services/pages.py b/lib/galaxy/webapps/galaxy/services/pages.py index 09ff71e0262..a5bafa99d5d 100644 --- a/lib/galaxy/webapps/galaxy/services/pages.py +++ b/lib/galaxy/webapps/galaxy/services/pages.py @@ -8,7 +8,6 @@ from galaxy.managers.markdown_util import ( internal_galaxy_markdown_to_pdf, to_basic_markdown, ) -from galaxy.managers.notification import NotificationManager from galaxy.managers.pages import ( PageManager, PageSerializer, @@ -33,6 +32,7 @@ from galaxy.webapps.galaxy.services.base import ( ensure_celery_tasks_enabled, ServiceBase, ) +from galaxy.webapps.galaxy.services.notifications import NotificationService from galaxy.webapps.galaxy.services.sharable import ShareableService log = logging.getLogger(__name__) @@ -51,12 +51,12 @@ class PagesService(ServiceBase): manager: PageManager, serializer: PageSerializer, short_term_storage_allocator: ShortTermStorageAllocator, - notification_manager: NotificationManager, + notification_service: NotificationService, ): super().__init__(security) self.manager = manager self.serializer = serializer - self.shareable_service = ShareableService(self.manager, self.serializer, notification_manager) + self.shareable_service = ShareableService(self.manager, self.serializer, notification_service) self.short_term_storage_allocator = short_term_storage_allocator def index( diff --git a/lib/galaxy/webapps/galaxy/services/sharable.py b/lib/galaxy/webapps/galaxy/services/sharable.py index 73724ba6e28..7d5bc5cfe54 100644 --- a/lib/galaxy/webapps/galaxy/services/sharable.py +++ b/lib/galaxy/webapps/galaxy/services/sharable.py @@ -12,7 +12,6 @@ from typing import ( from sqlalchemy import false from galaxy.managers import base -from galaxy.managers.notification import NotificationManager from galaxy.managers.sharable import ( SharableModelManager, SharableModelSerializer, @@ -41,6 +40,7 @@ from galaxy.schema.schema import ( SharingStatus, UserIdentifier, ) +from galaxy.webapps.galaxy.services.notifications import NotificationService log = logging.getLogger(__name__) @@ -67,11 +67,11 @@ class ShareableService: self, manager: SharableModelManager, serializer: SharableModelSerializer, - notification_manager: NotificationManager, + notification_service: NotificationService, ) -> None: self.manager = manager self.serializer = serializer - self.notification_manager = notification_manager + self.notification_service = notification_service def set_slug(self, trans, id: DecodedDatabaseIdField, payload: SetSlugPayload): item = self._get_item_by_id(trans, id) @@ -174,9 +174,13 @@ class ShareableService: return send_to_users, send_to_err def _send_notification_to_users(self, users_to_notify: Set[User], item: SharableItem, status: ShareWithStatus): - if self.notification_manager.notifications_enabled and not status.errors and users_to_notify: + if ( + self.notification_service.notification_manager.notifications_enabled + and not status.errors + and users_to_notify + ): request = SharedItemNotificationFactory.build_notification_request(item, users_to_notify, status) - self.notification_manager.send_notification_to_recipients(request) + self.notification_service.send_notification_internal(request) class SharedItemNotificationFactory: diff --git a/lib/galaxy/webapps/galaxy/services/visualizations.py b/lib/galaxy/webapps/galaxy/services/visualizations.py index a5017a76067..0138de78d9f 100644 --- a/lib/galaxy/webapps/galaxy/services/visualizations.py +++ b/lib/galaxy/webapps/galaxy/services/visualizations.py @@ -2,7 +2,6 @@ import logging from typing import Tuple from galaxy import exceptions -from galaxy.managers.notification import NotificationManager from galaxy.managers.visualizations import ( VisualizationManager, VisualizationSerializer, @@ -13,6 +12,7 @@ from galaxy.schema.visualization import ( ) from galaxy.security.idencoding import IdEncodingHelper from galaxy.webapps.galaxy.services.base import ServiceBase +from galaxy.webapps.galaxy.services.notifications import NotificationService from galaxy.webapps.galaxy.services.sharable import ShareableService log = logging.getLogger(__name__) @@ -30,12 +30,12 @@ class VisualizationsService(ServiceBase): security: IdEncodingHelper, manager: VisualizationManager, serializer: VisualizationSerializer, - notification_manager: NotificationManager, + notification_service: NotificationService, ): super().__init__(security) self.manager = manager self.serializer = serializer - self.shareable_service = ShareableService(self.manager, self.serializer, notification_manager) + self.shareable_service = ShareableService(self.manager, self.serializer, notification_service) # TODO: add the rest of the API actions here and call them directly from the API controller diff --git a/lib/galaxy/webapps/galaxy/services/workflows.py b/lib/galaxy/webapps/galaxy/services/workflows.py index 21f7062dc76..b1079ac9cee 100644 --- a/lib/galaxy/webapps/galaxy/services/workflows.py +++ b/lib/galaxy/webapps/galaxy/services/workflows.py @@ -13,7 +13,6 @@ from galaxy import ( web, ) from galaxy.managers.context import ProvidesUserContext -from galaxy.managers.notification import NotificationManager from galaxy.managers.workflows import ( RefactorResponse, WorkflowContentsManager, @@ -33,6 +32,7 @@ from galaxy.schema.workflows import ( ) from galaxy.util.tool_shed.tool_shed_registry import Registry from galaxy.webapps.galaxy.services.base import ServiceBase +from galaxy.webapps.galaxy.services.notifications import NotificationService from galaxy.webapps.galaxy.services.sharable import ShareableService from galaxy.workflow.run import queue_invoke from galaxy.workflow.run_request import build_workflow_run_configs @@ -51,12 +51,12 @@ class WorkflowsService(ServiceBase): workflow_contents_manager: WorkflowContentsManager, serializer: WorkflowSerializer, tool_shed_registry: Registry, - notification_manager: NotificationManager, + notification_service: NotificationService, ): self._workflows_manager = workflows_manager self._workflow_contents_manager = workflow_contents_manager self._serializer = serializer - self.shareable_service = ShareableService(workflows_manager, serializer, notification_manager) + self.shareable_service = ShareableService(workflows_manager, serializer, notification_service) self._tool_shed_registry = tool_shed_registry def index(