Module: Moderate::Moderation
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/controllers/concerns/moderate/moderation.rb
Overview
Drop-in admin moderation actions for a host's admin controller (BYOUI).
class Admin::ReportsController < ApplicationController
include Moderate::Moderation # resolve/dismiss (+ uphold/reject) actions
before_action :require_admin # you bring auth
end
moderate deliberately ships NO admin UI — Trust & Safety chrome (branding,
auth, layout) is the part every app wants to own. What it DOES own is the
decision logic: every status change must go through the model's atomic
decision method (resolve!/dismiss!/uphold!/reject!) so content removal,
bans, the notify/audit hooks, the DSA Art. 17 statement-of-reasons, and the
Art. 20 appeal window all happen together-or-not-at-all. This concern is the
thin HTTP glue that calls those methods, so a host gets the standard wiring for
free and never hand-rolls a raw status = "..." update (which would skip every
one of those guarantees). See docs/madmin.md.
The actions assume @record is already loaded (madmin's ResourceController and
most admin frameworks set it from the member route). If yours doesn't, override
moderation_record below.
Instance Method Summary collapse
-
#dismiss ⇒ Object
Dismiss (action) a report/flag: no violation found.
- #reject ⇒ Object
-
#resolve ⇒ Object
Resolve (action) a report/flag: optionally remove the offending content and/or ban the responsible user, always with a moderator + a note.
-
#uphold ⇒ Object
--- Appeal decisions (DSA Art. 20) -------------------------------------- An appeal is a free, electronic, human-decided internal complaint against a decision.
Instance Method Details
#dismiss ⇒ Object
Dismiss (action) a report/flag: no violation found. Note still required.
48 49 50 51 52 53 54 |
# File 'app/controllers/concerns/moderate/moderation.rb', line 48 def dismiss record = moderation_record record.dismiss!(by: moderation_actor, note: moderation_note) redirect_after_moderation(record, notice: moderation_t(:dismissed)) rescue => error redirect_after_moderation(record, alert: moderation_error(:dismiss, error)) end |
#reject ⇒ Object
69 70 71 72 73 74 75 |
# File 'app/controllers/concerns/moderate/moderation.rb', line 69 def reject record = moderation_record record.reject!(by: moderation_actor, note: moderation_note) redirect_after_moderation(record, notice: moderation_t(:rejected)) rescue => error redirect_after_moderation(record, alert: moderation_error(:reject, error)) end |
#resolve ⇒ Object
Resolve (action) a report/flag: optionally remove the offending content and/or ban the responsible user, always with a moderator + a note.
remove_content/ban_user come from the form as checkboxes ("1"/"0"); the
model casts them, but we pass them through untouched so the model stays the one
place that interprets them. note is required by the model (it feeds the
statement of reasons) — we let the model raise and turn that into a flash.
39 40 41 42 43 44 45 |
# File 'app/controllers/concerns/moderate/moderation.rb', line 39 def resolve record = moderation_record record.resolve!(**moderation_decision_params) redirect_after_moderation(record, notice: moderation_t(:resolved)) rescue => error redirect_after_moderation(record, alert: moderation_error(:resolve, error)) end |
#uphold ⇒ Object
--- Appeal decisions (DSA Art. 20) --------------------------------------
An appeal is a free, electronic, human-decided internal complaint against a
decision. uphold! OVERTURNS the original decision; reject! CONFIRMS it.
https://eur-lex.europa.eu/eli/reg/2022/2065/oj (Article 20)
61 62 63 64 65 66 67 |
# File 'app/controllers/concerns/moderate/moderation.rb', line 61 def uphold record = moderation_record record.uphold!(by: moderation_actor, note: moderation_note) redirect_after_moderation(record, notice: moderation_t(:upheld)) rescue => error redirect_after_moderation(record, alert: moderation_error(:uphold, error)) end |