From 5ebb35c1619972c932a813ce4b88dce458fd8704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Wed, 27 May 2020 15:15:37 +0200 Subject: [PATCH] new: Add redirects in notifications, optional reply-to --- config/email.tmpl | 2 ++ lookyloo/lookyloo.py | 14 +++++++++++++- website/web/__init__.py | 3 ++- website/web/templates/tree.html | 4 ++++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/config/email.tmpl b/config/email.tmpl index 325fec7..8f1afdf 100644 --- a/config/email.tmpl +++ b/config/email.tmpl @@ -3,6 +3,8 @@ Dear {recipient}, Please have a look at this capture on lookyloo: * https://{domain}/tree/{uuid} +{redirects} + {comment} diff --git a/lookyloo/lookyloo.py b/lookyloo/lookyloo.py index a6f8ecf..3933e81 100644 --- a/lookyloo/lookyloo.py +++ b/lookyloo/lookyloo.py @@ -252,12 +252,23 @@ class Lookyloo(): return pickle.load(_p) return None - def send_mail(self, capture_uuid: str, comment: str='') -> None: + def send_mail(self, capture_uuid: str, email: str='', comment: str='') -> None: if not self.get_config('enable_mail_notification'): return + + redirects = '' + capture_dir = self.lookup_capture_dir(capture_uuid) + if capture_dir: + cache = self.capture_cache(capture_dir) + if cache: + redirects = "Redirects:\n" + redirects += '\n'.join(cache['redirects']) + email_config = self.get_config('email') msg = EmailMessage() msg['From'] = email_config['from'] + if email: + msg['Reply-To'] = email msg['To'] = email_config['to'] msg['Subject'] = email_config['subject'] body = get_email_template() @@ -265,6 +276,7 @@ class Lookyloo(): recipient=msg['To'].addresses[0].display_name, domain=email_config['domain'], uuid=capture_uuid, + redirects=redirects, comment=comment, sender=msg['From'].addresses[0].display_name, ) diff --git a/website/web/__init__.py b/website/web/__init__.py index 99a7acc..37f3a84 100644 --- a/website/web/__init__.py +++ b/website/web/__init__.py @@ -377,8 +377,9 @@ def cache_tree(tree_uuid: str): @app.route('/tree//send_mail', methods=['POST', 'GET']) def send_mail(tree_uuid: str): + email: str = request.form.get('email') if request.form.get('email') else '' # type: ignore comment: str = request.form.get('comment') if request.form.get('comment') else '' # type: ignore - lookyloo.send_mail(tree_uuid, comment) + lookyloo.send_mail(tree_uuid, email, comment) return redirect(url_for('tree', tree_uuid=tree_uuid)) diff --git a/website/web/templates/tree.html b/website/web/templates/tree.html index c1706f4..b35ca40 100644 --- a/website/web/templates/tree.html +++ b/website/web/templates/tree.html @@ -216,6 +216,10 @@