-
-
Notifications
You must be signed in to change notification settings - Fork 942
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1346 from Kathenae/bugfix/task-notification-plugi…
…n-db-save Bugfix: Task notification plugin fails to send email notifications in production mode
- Loading branch information
Showing
1 changed file
with
36 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,39 @@ | ||
import os | ||
import configparser | ||
def load(): | ||
from app.plugins.functions import get_current_plugin | ||
plugin = get_current_plugin(only_active=True) | ||
data_store = plugin.get_global_data_store() | ||
|
||
script_dir = os.path.dirname(os.path.abspath(__file__)) | ||
smtp_configuration = { | ||
'smtp_server': data_store.get_string('smtp_server', default=""), | ||
'smtp_port': data_store.get_int('smtp_port', default=587), | ||
'smtp_username': data_store.get_string('smtp_username', default=""), | ||
'smtp_password': data_store.get_string('smtp_password', default=""), | ||
'smtp_use_tls': data_store.get_bool('smtp_use_tls', default=False), | ||
'smtp_from_address': data_store.get_string('smtp_from_address', default=""), | ||
'smtp_to_address': data_store.get_string('smtp_to_address', default=""), | ||
'notification_app_name': data_store.get_string('notification_app_name', default=""), | ||
'notify_task_completed': data_store.get_bool('notify_task_completed', default=False), | ||
'notify_task_failed': data_store.get_bool('notify_task_failed', default=False), | ||
'notify_task_removed': data_store.get_bool('notify_task_removed', default=False) | ||
} | ||
return smtp_configuration | ||
|
||
def load(): | ||
config = configparser.ConfigParser() | ||
config.read(f"{script_dir}/.conf") | ||
smtp_configuration = { | ||
'smtp_server': config.get('SETTINGS', 'smtp_server', fallback=""), | ||
'smtp_port': config.getint('SETTINGS', 'smtp_port', fallback=587), | ||
'smtp_username': config.get('SETTINGS', 'smtp_username', fallback=""), | ||
'smtp_password': config.get('SETTINGS', 'smtp_password', fallback=""), | ||
'smtp_use_tls': config.getboolean('SETTINGS', 'smtp_use_tls', fallback=False), | ||
'smtp_from_address': config.get('SETTINGS', 'smtp_from_address', fallback=""), | ||
'smtp_to_address': config.get('SETTINGS', 'smtp_to_address', fallback=""), | ||
'notification_app_name': config.get('SETTINGS', 'notification_app_name', fallback=""), | ||
'notify_task_completed': config.getboolean('SETTINGS', 'notify_task_completed', fallback=False), | ||
'notify_task_failed': config.getboolean('SETTINGS', 'notify_task_failed', fallback=False), | ||
'notify_task_removed': config.getboolean('SETTINGS', 'notify_task_removed', fallback=False) | ||
} | ||
return smtp_configuration | ||
|
||
def save(data : dict): | ||
config = configparser.ConfigParser() | ||
config['SETTINGS'] = { | ||
'smtp_server': str(data.get('smtp_server')), | ||
'smtp_port': str(data.get('smtp_port')), | ||
'smtp_username': str(data.get('smtp_username')), | ||
'smtp_password': str(data.get('smtp_password')), | ||
'smtp_use_tls': str(data.get('smtp_use_tls')), | ||
'smtp_from_address': str(data.get('smtp_from_address')), | ||
'smtp_to_address': str(data.get('smtp_to_address')), | ||
'notification_app_name': str(data.get('notification_app_name')), | ||
'notify_task_completed': str(data.get('notify_task_completed')), | ||
'notify_task_failed': str(data.get('notify_task_failed')), | ||
'notify_task_removed': str(data.get('notify_task_removed')) | ||
} | ||
with open(f"{script_dir}/.conf", 'w') as configFile: | ||
config.write(configFile) | ||
def save(data: dict): | ||
from app.plugins.functions import get_current_plugin | ||
plugin = get_current_plugin(only_active=True) | ||
data_store = plugin.get_global_data_store() | ||
|
||
data_store.set_string('smtp_server', data.get('smtp_server')), | ||
data_store.set_int('smtp_port', data.get('smtp_port')), | ||
data_store.set_string('smtp_username', data.get('smtp_username')), | ||
data_store.set_string('smtp_password', data.get('smtp_password')), | ||
data_store.set_bool('smtp_use_tls', data.get('smtp_use_tls')), | ||
data_store.set_string('smtp_from_address', data.get('smtp_from_address')), | ||
data_store.set_string('smtp_to_address', data.get('smtp_to_address')), | ||
data_store.set_string('notification_app_name', | ||
data.get('notification_app_name')), | ||
data_store.set_bool('notify_task_completed', | ||
data.get('notify_task_completed')), | ||
data_store.set_bool('notify_task_failed', data.get('notify_task_failed')), | ||
data_store.set_bool('notify_task_removed', data.get('notify_task_removed')) |