| 9 | |
| 10 | |
| 11 | def send_comment_email(comment): |
| 12 | site = get_current_site().domain |
| 13 | subject = _('Thanks for your comment') |
| 14 | article_url = f"https://{site}{comment.article.get_absolute_url()}" |
| 15 | html_content = _("""<p>Thank you very much for your comments on this site</p> |
| 16 | You can visit <a href="%(article_url)s" rel="bookmark">%(article_title)s</a> |
| 17 | to review your comments, |
| 18 | Thank you again! |
| 19 | <br /> |
| 20 | If the link above cannot be opened, please copy this link to your browser. |
| 21 | %(article_url)s""") % {'article_url': article_url, 'article_title': comment.article.title} |
| 22 | tomail = comment.author.email |
| 23 | send_email([tomail], subject, html_content) |
| 24 | try: |
| 25 | if comment.parent_comment: |
| 26 | html_content = _("""Your comment on <a href="%(article_url)s" rel="bookmark">%(article_title)s</a><br/> has |
| 27 | received a reply. <br/> %(comment_body)s |
| 28 | <br/> |
| 29 | go check it out! |
| 30 | <br/> |
| 31 | If the link above cannot be opened, please copy this link to your browser. |
| 32 | %(article_url)s |
| 33 | """) % {'article_url': article_url, 'article_title': comment.article.title, |
| 34 | 'comment_body': comment.parent_comment.body} |
| 35 | tomail = comment.parent_comment.author.email |
| 36 | send_email([tomail], subject, html_content) |
| 37 | except Exception as e: |
| 38 | logger.error(e) |