From fab6362144b3dbabee9cecde391ae5b0db0936af Mon Sep 17 00:00:00 2001 From: Ionesio Junior Date: Wed, 14 Feb 2024 11:39:55 -0300 Subject: [PATCH 1/2] Turn off notifier service --- .../src/syft/service/notifier/notifier_service.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/syft/src/syft/service/notifier/notifier_service.py b/packages/syft/src/syft/service/notifier/notifier_service.py index 687eb4dfe85..35ac411fef3 100644 --- a/packages/syft/src/syft/service/notifier/notifier_service.py +++ b/packages/syft/src/syft/service/notifier/notifier_service.py @@ -51,9 +51,15 @@ def turn_off( self, context: AuthedServiceContext, ) -> Union[SyftSuccess, SyftError]: - return SyftError(message="Not Implemented") - # Set Notifier Model active field to False - # Store the current state of the notifier in the stash + result = self.stash.get(credentials=context.credentials) + + if result.is_err(): + return SyftError(message=result.err()) + + notifier = result.ok() + notifier.active = False + result = self.stash.update(credentials=context.credentials, settings=notifier) + return SyftSuccess(message="Notifier turned off") @service_method( path="notifier.enable_notifications", From 69ef589c354a73ee923259364fa66717f6aaeb4b Mon Sep 17 00:00:00 2001 From: Ionesio Junior Date: Wed, 14 Feb 2024 12:04:20 -0300 Subject: [PATCH 2/2] ADD checks for notifier.turn_off update result --- packages/syft/src/syft/service/notifier/notifier_service.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/syft/src/syft/service/notifier/notifier_service.py b/packages/syft/src/syft/service/notifier/notifier_service.py index 35ac411fef3..aceea1760ab 100644 --- a/packages/syft/src/syft/service/notifier/notifier_service.py +++ b/packages/syft/src/syft/service/notifier/notifier_service.py @@ -59,6 +59,8 @@ def turn_off( notifier = result.ok() notifier.active = False result = self.stash.update(credentials=context.credentials, settings=notifier) + if result.is_err(): + return SyftError(message=result.err()) return SyftSuccess(message="Notifier turned off") @service_method(