mirror of https://github.com/CIRCL/lookyloo
new: Add redirects in notifications, optional reply-to
parent
ccad142dd0
commit
5ebb35c161
|
@ -3,6 +3,8 @@ Dear {recipient},
|
|||
Please have a look at this capture on lookyloo:
|
||||
* https://{domain}/tree/{uuid}
|
||||
|
||||
{redirects}
|
||||
|
||||
{comment}
|
||||
|
||||
|
||||
|
|
|
@ -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,
|
||||
)
|
||||
|
|
|
@ -377,8 +377,9 @@ def cache_tree(tree_uuid: str):
|
|||
|
||||
@app.route('/tree/<string:tree_uuid>/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))
|
||||
|
||||
|
||||
|
|
|
@ -216,6 +216,10 @@
|
|||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label for="email">Email address - used to get back in touch with you if needed (optional)</label>
|
||||
<input type="email" class="form-control" name="email" id="email" placeholder="Enter email">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="comment">Please write a comment (optional)</label>
|
||||
<textarea class="form-control" name="comment" id=comment rows="3"></textarea>
|
||||
|
|
Loading…
Reference in New Issue