Class: Thredded::PostModerationRecord

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
ModerationState
Defined in:
app/models/thredded/post_moderation_record.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.record!(moderator:, post:, previous_moderation_state:, moderation_state:) ⇒ Thredded::PostModerationRecord

Returns the newly created persisted record.

Parameters:

Returns:


62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'app/models/thredded/post_moderation_record.rb', line 62

def self.record!(moderator:, post:, previous_moderation_state:, moderation_state:)
  # Rails 4 doesn't support enum _prefix
  previous_moderation_state = moderation_states[previous_moderation_state.to_s] if Rails::VERSION::MAJOR < 5
  create!(
    previous_moderation_state: previous_moderation_state,
    moderation_state:          moderation_state,
    moderator:                 moderator,
    post:                      post,
    post_content:              post.content,
    post_user:                 post.user,
    post_user_name:            post.user.try(:thredded_display_name),
    messageboard_id:           post.messageboard_id,
  )
end

Instance Method Details

#post_readersActiveRecord::Relation<Thredded.user_class>

Returns users that can read the moderated post.

Returns:

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

    users that can read the moderated post.


53
54
55
# File 'app/models/thredded/post_moderation_record.rb', line 53

def post_readers
  Thredded.user_class.thredded_messageboards_readers([messageboard])
end