Class: Moderate::Services::IntakeAppeal

Inherits:
Object
  • Object
show all
Defined in:
lib/moderate/services/intake_appeal.rb

Overview

IntakeAppeal — persistence path for a DSA Article 20 internal complaint (“appeal”) against a moderation decision.

Art. 20 requires an internal complaint-handling system that is FREE, by ELECTRONIC means, open for AT LEAST SIX MONTHS after the decision, and decided by a human (not solely automated). This service owns only the intake half: validating + persisting the complaint and emitting the ‘appeal_received` receipt. The human decision lives in ResolveAppeal. See: eur-lex.europa.eu/eli/reg/2022/2065/oj (Article 20).

The model enforces the legal preconditions (the report must be closed and its appeal window still open) as validations, so a save that violates them returns false with errors — this service doesn’t re-implement that, it just runs the surrounding side effects on success.

HOST-AGNOSTIC: the appellant may be a User (a logged-in affected party) OR an anonymous notifier (name + email) appealing a public-notice decision. We never assume a User.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(appeal:, report:, appellant: nil) ⇒ IntakeAppeal

Returns a new instance of IntakeAppeal.

Parameters:

  • appeal (Moderate::Appeal)

    an unsaved Appeal the caller has populated (reason, source, appellant contact). The caller owns strong-params; we own save + side effects.

  • report (Moderate::Report)

    the decision being appealed.

  • appellant (user_class, nil) (defaults to: nil)

    the complainant, when they’re a User.



29
30
31
32
# File 'lib/moderate/services/intake_appeal.rb', line 29

def initialize(appeal:, report:, appellant: nil)
  @appeal = appeal
  @appeal.assign_attributes(report: report, appellant: appellant)
end

Instance Attribute Details

#appealObject (readonly)

Returns the value of attribute appeal.



34
35
36
# File 'lib/moderate/services/intake_appeal.rb', line 34

def appeal
  @appeal
end

Instance Method Details

#saveObject



36
37
38
39
40
41
42
# File 'lib/moderate/services/intake_appeal.rb', line 36

def save
  return false unless appeal.save

  deliver_receipt
  audit_intake
  true
end