Module: Thredded::ContentModerationState Private

Extended by:
ActiveSupport::Concern
Includes:
ModerationState
Included in:
Post, Topic
Defined in:
app/models/concerns/thredded/content_moderation_state.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Moderation state of a piece of content, such as a Thredded::Topic or a Thredded::Post. Requires an integer moderation_state column, a user_id column, and a user_detail association on the including class.

Instance Method Summary collapse

Instance Method Details

#moderation_state_visible_to_all?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Whether this is visible to anyone based on the moderation state.

Returns:

  • (Boolean)


46
47
48
49
50
51
52
# File 'app/models/concerns/thredded/content_moderation_state.rb', line 46

def moderation_state_visible_to_all?
  if Thredded.content_visible_while_pending_moderation
    !blocked?
  else
    approved?
  end
end

#moderation_state_visible_to_user?(user) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Whether this is visible to the given user based on the moderation state.

Returns:

  • (Boolean)


55
56
57
58
59
# File 'app/models/concerns/thredded/content_moderation_state.rb', line 55

def moderation_state_visible_to_user?(user)
  moderation_state_visible_to_all? ||
    (!user.thredded_anonymous? &&
      (user_id == user.id || user.thredded_can_moderate_messageboards.map(&:id).include?(messageboard_id)))
end