From 8f88d2e5c2032451a7fcf29edc2e43eaf1e45fe9 Mon Sep 17 00:00:00 2001 From: Sameer Wagh Date: Mon, 15 Jul 2024 18:12:21 -0400 Subject: [PATCH 01/54] Added notification settings attribute to ServerSettings --- .../src/syft/service/settings/settings.py | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/packages/syft/src/syft/service/settings/settings.py b/packages/syft/src/syft/service/settings/settings.py index f3ea99a946f..19b643f8158 100644 --- a/packages/syft/src/syft/service/settings/settings.py +++ b/packages/syft/src/syft/service/settings/settings.py @@ -110,23 +110,27 @@ class ServerSettings(SyftObject): welcome_markdown: HTMLObject | MarkdownDescription = HTMLObject( text=DEFAULT_WELCOME_MSG ) + notifications_enabled: str = "Disabled" def _repr_html_(self) -> Any: - preferences = self._get_api().services.notifications.user_settings() - notifications = [] - if preferences.email: - notifications.append("email") - if preferences.sms: - notifications.append("sms") - if preferences.slack: - notifications.append("slack") - if preferences.app: - notifications.append("app") - - if notifications: - notifications_enabled = f"True via {', '.join(notifications)}" + if not self._get_api().services.notifications.settings().active: + self.notifications_enabled = "Disabled" else: - notifications_enabled = "False" + preferences = self._get_api().services.notifications.user_settings() + notifications = [] + if preferences.email: + notifications.append("email") + if preferences.sms: + notifications.append("sms") + if preferences.slack: + notifications.append("slack") + if preferences.app: + notifications.append("app") + + if notifications: + self.notifications_enabled = f"Enabled via {', '.join(notifications)}" + else: + self.notifications_enabled = "Disabled" return f"""