Skip to content

Commit

Permalink
Merge branch 'dev' into snwagh/adding-emails-to-sync-notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
snwagh authored Sep 18, 2024
2 parents 6cdae71 + 32896af commit 62695ba
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,24 +113,26 @@ spec:
key: rootPassword
- name: POSTGRESQL_DBNAME
value: {{ .Values.postgres.dbname | quote }}
{{- if .Values.server.smtp.enabled }}
# SMTP
- name: SMTP_HOST
value: {{ .Values.server.smtp.host | quote }}
value: {{ .Values.server.smtp.host | required "server.smtp.host is required" | quote }}
- name: SMTP_PORT
value: {{ .Values.server.smtp.port | quote }}
value: {{ .Values.server.smtp.port | required "server.smtp.port is required" | quote }}
- name: SMTP_USERNAME
value: {{ .Values.server.smtp.username | quote }}
value: {{ .Values.server.smtp.username | required "server.smtp.username is required" | quote }}
- name: SMTP_PASSWORD
{{- if .Values.server.smtp.existingSecret }}
valueFrom:
secretKeyRef:
name: {{ .Values.server.smtp.existingSecret }}
key: smtpPassword
{{ else }}
value: {{ .Values.server.smtp.password | quote }}
value: {{ .Values.server.smtp.password | required "server.smtp.password is required" | quote }}
{{ end }}
- name: EMAIL_SENDER
value: {{ .Values.server.smtp.from | quote}}
value: {{ .Values.server.smtp.from | required "server.smtp.from is required" | quote}}
{{- end }}
# SeaweedFS
{{- if ne .Values.server.type "gateway"}}
- name: S3_ROOT_USER
Expand Down
13 changes: 8 additions & 5 deletions packages/grid/helm/syft/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,16 @@ server:

# SMTP Settings
smtp:
enabled: false

host: null
port: null
from: null
username: null
password: null

# Existing secret for SMTP with key 'smtpPassword'
existingSecret: null
host: hostname
port: 587
from: [email protected]
username: apikey
password: password

# Extra environment vars
env: null
Expand Down
12 changes: 6 additions & 6 deletions packages/syft/src/syft/service/notifier/notifier_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,14 @@ def turn_on(
public_message="You must provide both server and port to enable notifications."
)

logging.debug("Got notifier from db")
logger.debug("Got notifier from db")
skip_auth: bool = False
# If no new credentials provided, check for existing ones
if not (email_username and email_password):
if not (notifier.email_username and notifier.email_password):
skip_auth = True
else:
logging.debug("No new credentials provided. Using existing ones.")
logger.debug("No new credentials provided. Using existing ones.")
email_password = notifier.email_password
email_username = notifier.email_username

Expand All @@ -150,7 +150,7 @@ def turn_on(
)

if not valid_credentials:
logging.error("Invalid SMTP credentials.")
logger.error("Invalid SMTP credentials.")
raise SyftException(public_message=("Invalid SMTP credentials."))

notifier.email_password = email_password
Expand Down Expand Up @@ -181,7 +181,7 @@ def turn_on(
notifier.email_sender = email_sender

notifier.active = True
logging.debug(
logger.debug(
"Email credentials are valid. Updating the notifier settings in the db."
)

Expand Down Expand Up @@ -238,7 +238,7 @@ def init_notifier(
email_sender: str | None = None,
smtp_port: int | None = None,
smtp_host: str | None = None,
) -> SyftSuccess:
) -> SyftSuccess | None:
"""Initialize Notifier settings for a Server.
If settings already exist, it will use the existing one.
If not, it will create a new one.
Expand Down Expand Up @@ -343,7 +343,7 @@ def dispatch_notification(

# If notifier is active
if notifier.active and notification.email_template is not None:
logging.debug("Checking user email activity")
logger.debug("Checking user email activity")

if notifier.email_activity.get(notification.email_template.__name__, None):
user_activity = notifier.email_activity[
Expand Down

0 comments on commit 62695ba

Please sign in to comment.