2024-09-17 14:43:34 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class AdminNotices::Dismiss
|
|
|
|
include Service::Base
|
|
|
|
|
|
|
|
policy :invalid_access
|
2024-10-18 17:13:34 +08:00
|
|
|
model :admin_notice, optional: true
|
2024-09-17 14:43:34 +08:00
|
|
|
transaction do
|
|
|
|
step :destroy
|
|
|
|
step :reset_problem_check
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def invalid_access(guardian:)
|
|
|
|
guardian.is_admin?
|
|
|
|
end
|
|
|
|
|
2024-10-18 17:13:34 +08:00
|
|
|
def fetch_admin_notice(id:)
|
|
|
|
AdminNotice.find_by(id: id)
|
|
|
|
end
|
|
|
|
|
2024-09-17 14:43:34 +08:00
|
|
|
def destroy(admin_notice:)
|
2024-10-07 12:29:33 +08:00
|
|
|
return if admin_notice.blank?
|
|
|
|
|
2024-09-17 14:43:34 +08:00
|
|
|
admin_notice.destroy!
|
|
|
|
end
|
|
|
|
|
|
|
|
def reset_problem_check(admin_notice:)
|
2024-10-07 12:29:33 +08:00
|
|
|
return if admin_notice.blank?
|
|
|
|
|
2024-09-17 14:43:34 +08:00
|
|
|
ProblemCheckTracker.find_by(identifier: admin_notice.identifier)&.reset
|
|
|
|
end
|
|
|
|
end
|