Browse Source

Add an option to toggle the email functionality from the client

The header of the POST method from the client should contain a new
property set to "Yes" if the log should be sent via email.
mario forzanini 2 years ago
parent
commit
23575c25e3
1 changed files with 5 additions and 2 deletions
  1. 5 2
      lcmlog-server

+ 5 - 2
lcmlog-server

@@ -69,9 +69,10 @@ def main():
 			if kind != "150" and kind != "Admin":	# We only have this two log types
 				raise KindError
 			if method == "POST":
+				send_mail = input()
 				auth(user_id, "POST", kind)     # Check if the user can post for the requested kind
 				log = sys.stdin.read() # Read the log content
-				method_post(kind, user_name, date, tags, log)
+				method_post(kind, user_name, date, tags, log, send_mail == "Yes")
 			elif method == "GET":
 				auth(user_id, "GET", kind)	# Check if the user can get logs for the requested kind
 				user_to_find = input() # Read the user name of the log writer to search
@@ -254,8 +255,10 @@ def method_get(kind, user_to_find, date, tags):
 
 
 # Write log
-def method_post(kind, user_name, date, tags, log):
+def method_post(kind, user_name, date, tags, log, send_mail):
 	name = log_create(kind, user_name, date, tags, log)
+	if send_mail:
+		log_mail(kind, user_name, date, tags, log)
 	logger.info("POST successful: hash " + name)