mirror of
https://github.com/discourse/discourse.git
synced 2025-05-26 06:01:43 +08:00
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:
@ -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
|
||||
|
Reference in New Issue
Block a user