mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 11:12:40 +08:00
FEATURE: allow users to easily track/watch/mute topics via email
If you reply to an email with the word "mute" a topic will be muted If you reply to an email with the word "track" a topic will be tracked If you reply to an email with the word "watch" a topic will be watched These ninja command can help advanced mailing list ex-users, saves a trip to the website
This commit is contained in:
@ -899,6 +899,22 @@ module Email
|
||||
create_post_with_attachments(options)
|
||||
end
|
||||
|
||||
def notification_level_for(body)
|
||||
# since we are stripping save all this work on long replies
|
||||
return nil if body.length > 40
|
||||
|
||||
body = body.strip.downcase
|
||||
case body
|
||||
when "mute"
|
||||
NotificationLevels.topic_levels[:muted]
|
||||
when "track"
|
||||
NotificationLevels.topic_levels[:tracking]
|
||||
when "watch"
|
||||
NotificationLevels.topic_levels[:watching]
|
||||
else nil
|
||||
end
|
||||
end
|
||||
|
||||
def create_reply(options = {})
|
||||
raise TopicNotFoundError if options[:topic].nil? || options[:topic].trashed?
|
||||
raise BouncedEmailError if options[:bounce] && options[:topic].archetype != Archetype.private_message
|
||||
@ -908,6 +924,8 @@ module Email
|
||||
|
||||
if post_action_type = post_action_for(options[:raw])
|
||||
create_post_action(options[:user], options[:post], post_action_type)
|
||||
elsif notification_level = notification_level_for(options[:raw])
|
||||
TopicUser.change(options[:user].id, options[:post].topic_id, notification_level: notification_level)
|
||||
else
|
||||
raise TopicClosedError if options[:topic].closed?
|
||||
options[:topic_id] = options[:topic].id
|
||||
|
Reference in New Issue
Block a user