Class: Thredded::Post

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
ContentModerationState, PostCommon
Defined in:
app/models/thredded/post.rb

Instance Method Summary collapse

Methods included from ContentModerationState

#moderation_state_visible_to_all?, #moderation_state_visible_to_user?

Methods included from PostCommon

#avatar_url, #calculate_page, #filtered_content

Instance Method Details

#page(per_page: self.class.default_per_page, user:) ⇒ Object

Parameters:

  • per_page (Integer) (defaults to: self.class.default_per_page)
  • user (Thredded.user_class)


36
37
38
39
# File 'app/models/thredded/post.rb', line 36

def page(per_page: self.class.default_per_page, user:)
  readable_posts = PostPolicy::Scope.new(user, postable.posts).resolve
  calculate_page(readable_posts, per_page)
end

#private_topic_post?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'app/models/thredded/post.rb', line 41

def private_topic_post?
  false
end

#readers_from_user_names(user_names) ⇒ ActiveRecord::Relation<Thredded.user_class>

Returns users from the list of user names that can read this post.

Returns:

  • (ActiveRecord::Relation<Thredded.user_class>)

    users from the list of user names that can read this post.



46
47
48
49
50
# File 'app/models/thredded/post.rb', line 46

def readers_from_user_names(user_names)
  DbTextSearch::CaseInsensitive
    .new(Thredded.user_class.thredded_messageboards_readers([messageboard]), Thredded.user_name_column)
    .in(user_names)
end