2024-09-17 14:43:34 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class AdminNotices::Dismiss
|
|
|
|
include Service::Base
|
|
|
|
|
2024-10-07 12:29:33 +08:00
|
|
|
model :admin_notice, optional: true
|
2024-09-17 14:43:34 +08:00
|
|
|
|
|
|
|
policy :invalid_access
|
|
|
|
|
|
|
|
transaction do
|
|
|
|
step :destroy
|
|
|
|
step :reset_problem_check
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def fetch_admin_notice(id:)
|
|
|
|
AdminNotice.find_by(id: id)
|
|
|
|
end
|
|
|
|
|
|
|
|
def invalid_access(guardian:)
|
|
|
|
guardian.is_admin?
|
|
|
|
end
|
|
|
|
|
|
|
|
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
|