-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor report creation into a service object
- Loading branch information
Showing
5 changed files
with
22 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,2 @@ | ||
class Federails::Moderation::Report | ||
def self.handle_flag(activity) | ||
Rails.logger.debug activity.inspect | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Federails::Moderation | ||
class ApplicationService | ||
def self.call(*args, &block) | ||
new(*args, &block).call | ||
end | ||
end | ||
end |
11 changes: 11 additions & 0 deletions
11
app/services/federails/moderation/report_creation_service.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Federails::Moderation | ||
class ReportCreationService < ApplicationService | ||
def initialize(activity) | ||
@activity = activity | ||
end | ||
|
||
def call | ||
Rails.logger.debug @activity.inspect | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
require "fediverse/inbox" | ||
|
||
Rails.application.config.after_initialize do | ||
Fediverse::Inbox.register_handler "Flag", "*", Federails::Moderation::Report, :handle_flag | ||
Fediverse::Inbox.register_handler "Flag", "*", Federails::Moderation::ReportCreationService, :call | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters