Class: Thredded::AtNotificationExtractor

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

Instance Method Summary collapse

Constructor Details

#initialize(post) ⇒ AtNotificationExtractor

Returns a new instance of AtNotificationExtractor.



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

def initialize(post)
  @post = post
end

Instance Method Details

#runArray<Thredded.user_class>

Returns:



10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/commands/thredded/at_notification_extractor.rb', line 10

def run
  view_context = Thredded::ApplicationController.new.view_context
  # Do not highlight @-mentions at first, because:
  # * When parsing, @-mentions within <a> tags will not be considered.
  # * We can't always generate the user URL here because request.host is not available.
  html = @post.filtered_content(view_context, users_provider: nil)
  Thredded::HtmlPipeline::AtMentionFilter.new(
    html,
    view_context: view_context,
    users_provider: ->(user_names) { @post.readers_from_user_names(user_names).to_a }
  ).mentioned_users
end