11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'app/commands/thredded/moderate_post.rb', line 11
def run!(post:, moderation_state:, moderator:)
Thredded::Post.transaction do
post_moderation_record = Thredded::PostModerationRecord.record!(
moderator: moderator,
post: post,
previous_moderation_state: post.moderation_state,
moderation_state: moderation_state,
)
if post.user_id && post.user_detail.pending_moderation?
update_without_timestamping!(post.user_detail, moderation_state: moderation_state)
end
if post.postable.first_post == post
update_without_timestamping!(post.postable, moderation_state: moderation_state)
if moderation_state == :blocked
post.postable.posts.where(user_id: post.user.id).where.not(id: post.id).each do |a_post|
update_without_timestamping!(a_post, moderation_state: moderation_state)
end
end
end
update_without_timestamping!(post, moderation_state: moderation_state)
post_moderation_record
end
end
|