464ecbb7ad985deb6116293dfe1a334e8d06d990 — emerson 6 days ago 166785b master
Add original comment in reply email
2 files changed, 13 insertions(+), 6 deletions(-)

M dronebl/config.example.yaml
M dronebl/dronebl_check_tickets.py
M dronebl/config.example.yaml => dronebl/config.example.yaml +7 -0
@@ 19,6 19,10 @@ email_inactive: |
   Hello,
   The DroneBL entry for {} has been removed.
   Please wait 30 minutes for the DNS zone file to be updated.
+
+  For reference, here is the comment you submitted
+  {}
+
 email_active: |
   Hello,
   The DroneBL removal request for {} has been denied. Details below:


@@ 26,3 30,6 @@ email_active: |
   {}
 
   Please fix this open proxy and then request removal again.
+
+  For reference, here is the comment you submitted
+  {}

M dronebl/dronebl_check_tickets.py => dronebl/dronebl_check_tickets.py +6 -6
@@ 20,13 20,13 @@ debug_log.debug(f"Current run at {datetime.now()}")
 s = requests.Session()
 headers = {"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:65.0) Gecko/20100101 Firefox/65.0"}
 
-def send_active_email(ticket, details):
+def send_active_email(ticket, details, comment):
 	auth_api = ("api", config["mg_api_key"])
 	data = {
 		"from": config["email_from"],
 		"to": ticket["email"],
 		"subject": f"DroneBL removal request for {ticket['ip']} denied",
-		"text": config["email_active"].format(ticket["ip"], details),
+		"text": config["email_active"].format(ticket["ip"], details, comment),
 	}
 	if config.get("email_bcc"):
 		data["bcc"] = config["email_bcc"]


@@ 36,13 36,13 @@ def send_active_email(ticket, details):
 	requests.post(f"https://api.mailgun.net/v3/{config['mg_domain_name']}/messages",
 			auth=auth_api, data=data)
 
-def send_inactive_email(ticket):
+def send_inactive_email(ticket, comment):
 	auth_api = ("api", config["mg_api_key"])
 	data = {
 		"from": config["email_from"],
 		"to": ticket["email"],
 		"subject": f"DroneBL entry for {ticket['ip']} removed",
-		"text": config["email_inactive"].format(ticket["ip"]),
+		"text": config["email_inactive"].format(ticket["ip"], comment),
 	}
 	if config.get("email_bcc"):
 		data["bcc"] = config["email_bcc"]


@@ 109,7 109,7 @@ with pgconn:
 							debug_log.debug(details)
 							s.post("https://dronebl.org/admin/tickets", headers=headers, data={"ajax": "delete", "id": ticket["ticket_id"]})
 							if not already_sent:
-								send_active_email(ticket, details)
+								send_active_email(ticket, details, comment.text)
 								debug_log.debug(f"Sent email: {details}")
 								already_sent = True
 							curs.execute("update proxies set recheck=false where id=%s", (entry[0],))


@@ 128,7 128,7 @@ with pgconn:
 				curs.execute("update proxies set recheck=false where ip=%s or exit_ip=%s", (ip, ip))
 				curs.execute("delete from dronebl where ip=%s", (ip,))
 				pgconn.commit()
-				send_inactive_email(ticket)
+				send_inactive_email(ticket, comment.text)
 				time.sleep(5)
 
 if entries_to_remove: