Sha256: 541a9fcfbeecb4c91a3674b8af7ab27e5ea3ac9254ca07690ebababb8f45ab68

Contents?: true

Size: 782 Bytes

Versions: 10

Compression:

Stored size: 782 Bytes

Contents

# frozen_string_literal: true
module Thredded
  class AtNotificationExtractor
    def initialize(post)
      @post = post
    end

    # @return [Array<Thredded.user_class>]
    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
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
thredded-0.12.1 app/commands/thredded/at_notification_extractor.rb
thredded-0.12.0 app/commands/thredded/at_notification_extractor.rb
thredded-0.11.1 app/commands/thredded/at_notification_extractor.rb
thredded-0.11.0 app/commands/thredded/at_notification_extractor.rb
thredded-0.10.1 app/commands/thredded/at_notification_extractor.rb
thredded-0.10.0 app/commands/thredded/at_notification_extractor.rb
thredded-0.9.4 app/commands/thredded/at_notification_extractor.rb
thredded-0.9.3 app/commands/thredded/at_notification_extractor.rb
thredded-0.9.2 app/commands/thredded/at_notification_extractor.rb
thredded-0.9.1 app/commands/thredded/at_notification_extractor.rb