Add support for email backend in config.
This commit is contained in:
parent
432f2854d5
commit
20d5c51016
14
server.py
14
server.py
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env python3
|
||||
"Server for the-long-night"
|
||||
|
||||
import subprocess
|
||||
import json
|
||||
|
@ -11,6 +12,7 @@ app = Flask(__name__)
|
|||
|
||||
@app.route('/login', methods=['POST'])
|
||||
def en_login():
|
||||
"/login"
|
||||
try:
|
||||
password = request.values['password']
|
||||
except KeyError:
|
||||
|
@ -35,26 +37,34 @@ def en_login():
|
|||
"and run `cancel-adding-key.sh` in The Long Night installation"
|
||||
"directory.")
|
||||
|
||||
if config["matrix"]["enabled"]:
|
||||
if "matrix" in config and config["matrix"]["enabled"]:
|
||||
from backends import matrix
|
||||
try:
|
||||
matrix.send(config["matrix"], message)
|
||||
except:
|
||||
pass
|
||||
|
||||
if config["telegram"]["enabled"]:
|
||||
if "telegram" in config and config["telegram"]["enabled"]:
|
||||
from backends import telegram
|
||||
try:
|
||||
telegram.send(config["telegram"], message)
|
||||
except:
|
||||
pass
|
||||
|
||||
if "email" in config and config["email"]["enabled"]:
|
||||
from backends import mail
|
||||
try:
|
||||
mail.send(config["email"], message)
|
||||
except:
|
||||
pass
|
||||
|
||||
return ("Logged In. The ssh key will be added " + str(config["days"]) +
|
||||
" day(s) later.")
|
||||
|
||||
|
||||
@app.route('/')
|
||||
def en_root():
|
||||
"/"
|
||||
return """
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
|
Loading…
Reference in New Issue