mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 02:04:53 +08:00
Unsubscribe via email
This commit is contained in:
@ -59,7 +59,10 @@ module Email
|
||||
|
||||
raise InactiveUserError if !user.active && !user.staged
|
||||
|
||||
if post = find_related_post
|
||||
if action = subscription_action_for(body, @mail.subject)
|
||||
message = SubscriptionMailer.send(action, user)
|
||||
Email::Sender.new(message, :subscription).send
|
||||
elsif post = find_related_post
|
||||
create_reply(user: user, raw: body, post: post, topic: post.topic)
|
||||
else
|
||||
destination = destinations.first
|
||||
@ -226,6 +229,13 @@ module Email
|
||||
@likes ||= Set.new ["+1", I18n.t('post_action_types.like.title').downcase]
|
||||
end
|
||||
|
||||
def subscription_action_for(body, subject)
|
||||
return unless SiteSetting.unsubscribe_via_email
|
||||
if ([subject, body].compact.map(&:to_s).map(&:downcase) & ['unsubscribe']).any?
|
||||
:confirm_unsubscribe
|
||||
end
|
||||
end
|
||||
|
||||
def post_action_for(body)
|
||||
if likes.include?(body.strip.downcase)
|
||||
PostActionType.types[:like]
|
||||
|
Reference in New Issue
Block a user