|
5 | 5 | ) |
6 | 6 |
|
7 | 7 | from galaxy.managers import base |
| 8 | +from galaxy.managers.notification import NotificationManager |
8 | 9 | from galaxy.managers.sharable import ( |
9 | 10 | SharableModelManager, |
10 | 11 | SharableModelSerializer, |
@@ -62,10 +63,12 @@ def __init__( |
62 | 63 | manager: SharableModelManager, |
63 | 64 | serializer: SharableModelSerializer, |
64 | 65 | notification_service: NotificationService, |
| 66 | + notification_manager: NotificationManager, |
65 | 67 | ) -> None: |
66 | 68 | self.manager = manager |
67 | 69 | self.serializer = serializer |
68 | 70 | self.notification_service = notification_service |
| 71 | + self.notification_manager = notification_manager |
69 | 72 |
|
70 | 73 | def set_slug(self, trans, id: DecodedDatabaseIdField, payload: SetSlugPayload): |
71 | 74 | item = self._get_item_by_id(trans, id) |
@@ -177,17 +180,13 @@ def _get_users(self, trans, emails_or_ids: list[UserIdentifier]) -> tuple[set[Us |
177 | 180 | def _send_notification_to_users( |
178 | 181 | self, users_to_notify: set[User], item: SharableItem, status: ShareWithStatus, galaxy_url: Optional[str] = None |
179 | 182 | ): |
180 | | - if ( |
181 | | - self.notification_service.notification_manager.notifications_enabled |
182 | | - and not status.errors |
183 | | - and users_to_notify |
184 | | - ): |
| 183 | + if self.notification_manager.notifications_enabled and not status.errors and users_to_notify: |
185 | 184 | request = SharedItemNotificationFactory.build_notification_request( |
186 | 185 | item, users_to_notify, status, galaxy_url |
187 | 186 | ) |
188 | 187 | # We can set force_sync=True here because we already have the set of users to notify |
189 | 188 | # and there is no need to resolve them asynchronously as no groups or roles are involved. |
190 | | - self.notification_service.notification_manager.send_notification_internal(request, force_sync=True) |
| 189 | + self.notification_manager.send_notification_internal(request, force_sync=True) |
191 | 190 |
|
192 | 191 |
|
193 | 192 | class SharedItemNotificationFactory: |
|
0 commit comments