unsubscribe to unread notifs email

This commit is contained in:
rimu 2024-02-24 14:19:07 +13:00
parent 28fa59a769
commit c36e6f1ad5
4 changed files with 28 additions and 3 deletions

View file

@ -15,5 +15,4 @@
{% endfor %}
</ul>
{% endif %}
<p><small><a href="{{ url_for('user.change_settings', _external=True) }}">Unsubscribe from these emails</a> by un-ticking the 'Receive email
about missed notifications' checkbox.</small></p>
<p><small><a href="{{ url_for('user.user_email_notifs_unsubscribe', user_id=user.id, token=user.verification_token, _external=True) }}">Unsubscribe from these emails</a></small></p>

View file

@ -5,4 +5,4 @@ Here's some notifications you've missed since your last visit:
- {{ notification.title }} - {{ url_for('user.notification_goto', notification_id=notification.id, _external=True) }}
{% endfor %}
Unsubscribe from these emails</a> by un-ticking the 'Receive email about missed notifications' checkbox at {{ url_for('user.change_settings', _external=True) }}.
Unsubscribe from these emails at {{ url_for('user.user_email_notifs_unsubscribe', user_id=user.id, token=user.verification_token, _external=True) }}.

View file

@ -0,0 +1,17 @@
{% extends 'base.html' %}
{% from 'bootstrap/form.html' import render_form %}
{% block app_content %}
<div class="row">
<div class="col col-login mx-auto">
<div class="card mt-5">
<div class="card-body p-6">
<div class="card-title text-center">{{ _('Unsubscribed') }}</div>
<p>{{ _('You have unsubscribed from emails about unread notifications. We might email you for other reasons, though.') }}</p>
<p><a href="{{ url_for('user.change_settings') }}">{{ _('More email settings') }}</a></p>
</div>
</div>
</div>
</div>
{% endblock %}

View file

@ -701,3 +701,12 @@ def user_newsletter_unsubscribe(user_id, token):
user.newsletter = False
db.session.commit()
return render_template('user/newsletter_unsubscribed.html')
@bp.route('/user/email_notifs/<int:user_id>/<token>/unsubscribe', methods=['GET', 'POST'])
def user_email_notifs_unsubscribe(user_id, token):
user = User.query.filter(User.id == user_id, User.verification_token == token).first()
if user:
user.email_unread = False
db.session.commit()
return render_template('user/email_notifs_unsubscribed.html')