DEV: removes default service actions (#26078)

Previously services would let you define a high level default `def default_actions_for_service; end` which would define various handlers like `on_success`, after months of usage we consider the cons are superior to the pros here.

Two mains cons:
- people would often not understand where the handling was coming from
- it's easy to miss a case when you write your specs
This commit is contained in:
Joffrey JAFFEUX
2024-03-07 12:10:43 +01:00
committed by GitHub
parent 9f523af19c
commit 821402d024
29 changed files with 184 additions and 35 deletions

View File

@ -3,18 +3,5 @@
module Chat
class ApiController < ::Chat::BaseController
include Chat::WithServiceHelper
private
def default_actions_for_service
proc do
on_success { render(json: success_json) }
on_failure { render(json: failed_json, status: 422) }
on_failed_policy(:invalid_access) { raise Discourse::InvalidAccess }
on_failed_contract do |contract|
render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)
end
end
end
end
end