mirror of
https://github.com/discourse/discourse.git
synced 2024-12-22 11:44:34 +08:00
2f334964f2
We decided to keep only one way to access values from a contract. This patch thus removes the hash-like access from contracts.
40 lines
712 B
Ruby
40 lines
712 B
Ruby
# frozen_string_literal: true
|
|
|
|
class AdminNotices::Dismiss
|
|
include Service::Base
|
|
|
|
policy :invalid_access
|
|
params do
|
|
attribute :id, :integer
|
|
|
|
validates :id, presence: true
|
|
end
|
|
model :admin_notice, optional: true
|
|
transaction do
|
|
step :destroy
|
|
step :reset_problem_check
|
|
end
|
|
|
|
private
|
|
|
|
def invalid_access(guardian:)
|
|
guardian.is_admin?
|
|
end
|
|
|
|
def fetch_admin_notice(params:)
|
|
AdminNotice.find_by(id: params.id)
|
|
end
|
|
|
|
def destroy(admin_notice:)
|
|
return if admin_notice.blank?
|
|
|
|
admin_notice.destroy!
|
|
end
|
|
|
|
def reset_problem_check(admin_notice:)
|
|
return if admin_notice.blank?
|
|
|
|
ProblemCheckTracker.find_by(identifier: admin_notice.identifier)&.reset
|
|
end
|
|
end
|