mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-22 05:52:11 +08:00
The staff action log records moderation actions (post deletions, user suspensions, silences, user approvals, etc.) as `UserHistory` rows, but entries triggered from the reviewable queue have no reference back to the reviewable that caused them. When auditing a decision in the log, staff can't jump to the flagged post, queued post, or user-approval review that produced it. Link to review is visible in the log: <img width="900" height="674" alt="Screenshot 2026-04-24 at 2 17 04 pm" src="https://github.com/user-attachments/assets/791ebc58-0a4d-4c2c-a363-efe482f5f755" />
61 lines
1.6 KiB
Ruby
Vendored
61 lines
1.6 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
class User::Suspend
|
|
include Service::Base
|
|
|
|
params do
|
|
attribute :user_id, :integer
|
|
attribute :reason, :string
|
|
attribute :message, :string
|
|
attribute :suspend_until, :datetime
|
|
attribute :other_user_ids, :array
|
|
attribute :post_id, :integer
|
|
attribute :post_action, :string
|
|
attribute :post_edit, :string
|
|
attribute :reviewable_id, :integer
|
|
|
|
validates :user_id, presence: true
|
|
validates :reason, presence: true, length: { maximum: 300 }
|
|
validates :suspend_until, presence: true
|
|
validates :other_user_ids, length: { maximum: User::MAX_SIMILAR_USERS }
|
|
validates :post_action,
|
|
inclusion: {
|
|
in: %w[delete delete_replies delete_all edit none],
|
|
},
|
|
allow_blank: true
|
|
end
|
|
|
|
model :user
|
|
policy :not_suspended_already, class_name: User::Policy::NotAlreadySuspended
|
|
model :users
|
|
policy :can_suspend_all_users
|
|
step :suspend
|
|
model :post, optional: true
|
|
step :perform_post_action
|
|
|
|
private
|
|
|
|
def fetch_user(params:)
|
|
User.find_by(id: params.user_id)
|
|
end
|
|
|
|
def fetch_users(user:, params:)
|
|
[user, *User.where(id: params.other_user_ids.to_a.uniq).to_a]
|
|
end
|
|
|
|
def can_suspend_all_users(guardian:, users:)
|
|
users.all? { guardian.can_suspend?(it) }
|
|
end
|
|
|
|
def suspend(guardian:, users:, params:)
|
|
context[:full_reason] = User::Action::SuspendAll.call(users:, actor: guardian.user, params:)
|
|
end
|
|
|
|
def fetch_post(params:)
|
|
Post.find_by(id: params.post_id)
|
|
end
|
|
|
|
def perform_post_action(guardian:, post:, params:)
|
|
User::Action::TriggerPostAction.call(guardian:, post:, params:)
|
|
end
|
|
end
|