Skip to content

Commit

Permalink
Trigger report event creation when a report is created
Browse files Browse the repository at this point in the history
  • Loading branch information
krauselukas authored and danidoni committed Sep 22, 2023
1 parent 9708deb commit 9898bc2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/api/app/models/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ class Report < ApplicationRecord
belongs_to :reportable, polymorphic: true, optional: true

belongs_to :decision, optional: true

after_create :create_event

private

def create_event
Event::CreateReport.create(event_parameters)
end

def event_parameters
{ id: id, user_id: user_id, reportable_id: reportable_id, reportable_type: reportable_type, reason: reason }
end
end

# == Schema Information
Expand Down

0 comments on commit 9898bc2

Please sign in to comment.