Allow email to be disabled.

The config file defaults to email being off now.  This requires
the user to set the email settings anyway, so the default is off.
This commit is contained in:
Hemna 2021-01-21 13:50:19 -05:00
parent a656508ba6
commit 982f24c5f5
2 changed files with 19 additions and 8 deletions

View File

@ -417,12 +417,17 @@ def server(
setup_logging(config, loglevel, quiet)
LOG.info("APRSD Started version: {}".format(aprsd.__version__))
# TODO(walt): Make email processing/checking optional?
# Maybe someone only wants this to process messages with plugins only.
valid = email.validate_email_config(config, disable_validation)
if not valid:
LOG.error("Failed to validate email config options")
sys.exit(-1)
email_enabled = config["aprsd"]["email"].get("enabled", False)
if email_enabled:
# TODO(walt): Make email processing/checking optional?
# Maybe someone only wants this to process messages with plugins only.
valid = email.validate_email_config(config, disable_validation)
if not valid:
LOG.error("Failed to validate email config options")
sys.exit(-1)
else:
LOG.info("Email services not enabled.")
# Create the initial PM singleton and Register plugins
plugin_manager = plugin.PluginManager(config)
@ -448,8 +453,11 @@ def server(
rx_thread = threads.APRSDRXThread(msg_queues=msg_queues, config=config)
tx_thread = threads.APRSDTXThread(msg_queues=msg_queues, config=config)
email_thread = email.APRSDEmailThread(msg_queues=msg_queues, config=config)
email_thread.start()
if email_enabled:
email_thread = email.APRSDEmailThread(msg_queues=msg_queues, config=config)
email_thread.start()
rx_thread.start()
tx_thread.start()

View File

@ -21,6 +21,9 @@ class EmailPlugin(plugin.APRSDPluginBase):
def command(self, fromcall, message, ack):
LOG.info("Email COMMAND")
reply = None
if not self.config["aprsd"]["email"].get("enabled", False):
LOG.debug("Email is not enabled in config file ignoring.")
return "Email not enabled."
searchstring = "^" + self.config["ham"]["callsign"] + ".*"
# only I can do email