diff --git a/funnel/views/notifications/account_notification.py b/funnel/views/notifications/account_notification.py index 1a1a526f2..f8f63140b 100644 --- a/funnel/views/notifications/account_notification.py +++ b/funnel/views/notifications/account_notification.py @@ -2,17 +2,37 @@ from __future__ import annotations -from flask import render_template, url_for +from flask import render_template from baseframe import _, __ from ... import app from ...models import Account, AccountPasswordNotification -from ...transports.sms import OneLineTemplate -from ..helpers import shortlink +from ...transports.sms import SmsTemplate from ..notification import RenderNotification +class PasswordResetNotificationTemplate(SmsTemplate): + """DLT registered template for Password Reset.""" + + registered_template = ( + "Your password has been updated. If this was not authorized," + " reset your password or contact support at {#var#}." + "\n\nhttps://bye.li to unsubscribe -Hasgeek" + ) + template = ( + "Your password has been updated. If this was not authorized," + " reset your password or contact support at {email}." + "\n\nhttps://bye.li to unsubscribe -Hasgeek" + ) + plaintext_template = ( + "Your password has been updated. If this was not authorized," + " reset your password or contact support at {email}." + ) + + email: str + + @AccountPasswordNotification.renderer class RenderAccountPasswordNotification(RenderNotification): """Notify user when their password is changed.""" @@ -45,14 +65,7 @@ def email_content(self): 'notifications/user_password_set_email.html.jinja2', view=self ) - def sms(self) -> OneLineTemplate: - return OneLineTemplate( - text1=_( - "Your password has been updated. If this was not authorized, reset" - " your password or contact support at {email}." - ).format(email=app.config['SITE_SUPPORT_EMAIL']), - url=shortlink( - url_for('reset', _external=True, **self.tracking_tags('sms')), - shorter=True, - ), + def sms(self) -> PasswordResetNotificationTemplate: + return PasswordResetNotificationTemplate( + email=app.config.get('SITE_SUPPORT_EMAIL') ) diff --git a/funnel/views/notifications/comment_notification.py b/funnel/views/notifications/comment_notification.py index 09a49e350..80535d6a6 100644 --- a/funnel/views/notifications/comment_notification.py +++ b/funnel/views/notifications/comment_notification.py @@ -20,7 +20,7 @@ Project, Proposal, ) -from ...transports.sms import OneLineTemplate, SmsPriority, SmsTemplate +from ...transports.sms import SmsPriority, SmsTemplate from ..helpers import shortlink from ..notification import RenderNotification from .mixins import TemplateVarMixin @@ -77,6 +77,14 @@ class CommentProjectTemplate(TemplateVarMixin, SmsTemplate): url: str +class CommentReportReceivedTemplate(SmsTemplate): + registered_template = 'A comment has been reported as spam: {#var#} -Hasgeek' + template = 'A comment has been reported as spam: {url} -Hasgeek' + plaintext_template = 'A comment has been reported as spam: {url}' + + url: str + + @CommentReportReceivedNotification.renderer class RenderCommentReportReceivedNotification(RenderNotification): """Notify site admins when a comment report is received.""" @@ -102,9 +110,8 @@ def email_content(self) -> str: 'notifications/comment_report_received_email.html.jinja2', view=self ) - def sms(self) -> OneLineTemplate: - return OneLineTemplate( - text1=_("A comment has been reported as spam."), + def sms(self) -> CommentReportReceivedTemplate: + return CommentReportReceivedTemplate( url=shortlink( url_for( 'siteadmin_review_comment', diff --git a/sample.env b/sample.env index 159905cbc..65699a954 100644 --- a/sample.env +++ b/sample.env @@ -243,3 +243,5 @@ FLASK_SMS_DLT_TEMPLATE_IDS__update_template=null FLASK_SMS_DLT_TEMPLATE_IDS__comment_project_template=null FLASK_SMS_DLT_TEMPLATE_IDS__comment_proposal_template=null FLASK_SMS_DLT_TEMPLATE_IDS__comment_reply_template=null +FLASK_SMS_DLT_TEMPLATE_IDS__comment_report_received_template=null +FLASK_SMS_DLT_TEMPLATE_IDS__password_reset_notification_template=null