FEATURE: Custom unsubscribe options (#17090)

With this change, plugins can create custom unsubscribe keys, extend the unsubscribe view with custom preferences, and decide how they are updated.
This commit is contained in:
Roman Rizzi
2022-06-21 15:49:47 -03:00
committed by GitHub
parent deee3c6f02
commit e0ba35350e
15 changed files with 376 additions and 246 deletions

View File

@@ -4,7 +4,7 @@ class SubscriptionMailer < ActionMailer::Base
include Email::BuildEmailHelper
def confirm_unsubscribe(user, opts = {})
unsubscribe_key = UnsubscribeKey.create_key_for(user, "all")
unsubscribe_key = UnsubscribeKey.create_key_for(user, UnsubscribeKey::ALL_TYPE)
build_email user.email,
template: "unsubscribe_mailer",
site_title: SiteSetting.title,

View File

@@ -216,6 +216,8 @@ class UserNotifications < ActionMailer::Base
def digest(user, opts = {})
build_summary_for(user)
@unsubscribe_key = UnsubscribeKey.create_key_for(@user, UnsubscribeKey::DIGEST_TYPE)
min_date = opts[:since] || user.last_emailed_at || user.last_seen_at || 1.month.ago
# Fetch some topics and posts to show
@@ -753,7 +755,6 @@ class UserNotifications < ActionMailer::Base
@header_bgcolor = ColorScheme.hex_for_name('header_background')
@anchor_color = ColorScheme.hex_for_name('tertiary')
@markdown_linker = MarkdownLinker.new(@base_url)
@unsubscribe_key = UnsubscribeKey.create_key_for(@user, "digest")
@disable_email_custom_styles = !SiteSetting.apply_custom_styles_to_digest
end