Skip to content

Commit 91e79cc

Browse files
authored
Fix saving email notification settings with an empty From address (#3408)
The backend input_sanity_check() throws a ValueError when the From address field in the email notification settings is empty, preventing the settings from being saved. The sanity-check regex requires at least one character. The frontend does not require this field to be set. The UI help mark says: “the first destination email address will be used if left blank." We now skip the sanity check for this field, but only when it is empty.
1 parent 1e38bef commit 91e79cc

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

motioneye/config.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,6 +1366,16 @@ def motion_camera_ui_to_dict(ui, prev_config=None):
13661366
),
13671367
)
13681368

1369+
if ui['email_notifications_from'] != '':
1370+
email_from = input_sanity_check(
1371+
emailValidRegExp,
1372+
ui['email_notifications_from'],
1373+
'email_notifications_from',
1374+
emailFailMessage,
1375+
)
1376+
else:
1377+
email_from = ''
1378+
13691379
line = (
13701380
"%(script)s '%(server)s' '%(port)s' '%(account)s' '%(password)s' '%(tls)s' '%(from)s' '%(to)s' "
13711381
"'motion_start' '%%t' '%%Y-%%m-%%dT%%H:%%M:%%S' '%(timespan)s'"
@@ -1378,12 +1388,7 @@ def motion_camera_ui_to_dict(ui, prev_config=None):
13781388
.replace(';', '\\;')
13791389
.replace('%', '%%'),
13801390
'tls': ui['email_notifications_smtp_tls'],
1381-
'from': input_sanity_check(
1382-
emailValidRegExp,
1383-
ui['email_notifications_from'],
1384-
'email_notifications_from',
1385-
emailFailMessage,
1386-
),
1391+
'from': email_from,
13871392
'to': emails,
13881393
'timespan': ui['email_notifications_picture_time_span'],
13891394
}

0 commit comments

Comments
 (0)