Class: Thredded::AutofollowMentionedUsers

Inherits:
Object
  • Object
show all
Defined in:
app/commands/thredded/autofollow_mentioned_users.rb

Instance Method Summary collapse

Constructor Details

#initialize(post) ⇒ AutofollowMentionedUsers

Returns a new instance of AutofollowMentionedUsers.



5
6
7
# File 'app/commands/thredded/autofollow_mentioned_users.rb', line 5

def initialize(post)
  @post = post
end

Instance Method Details

#autofollowersObject



15
16
17
18
19
# File 'app/commands/thredded/autofollow_mentioned_users.rb', line 15

def autofollowers
  autofollowers = Thredded::AtNotificationExtractor.new(post).run
  autofollowers.delete(post.user)
  exclude_those_opting_out_of_at_notifications autofollowers
end

#runObject



9
10
11
12
13
# File 'app/commands/thredded/autofollow_mentioned_users.rb', line 9

def run
  autofollowers.each do |user|
    Thredded::UserTopicFollow.create_unless_exists(user.id, post.postable_id, :mentioned)
  end
end