11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'app/controllers/collavre_openclaw/callbacks_controller.rb', line 11
def create
user = User.find_by(id: params[:user_id])
unless user
render json: { error: "User not found" }, status: :not_found
return
end
begin
payload = JSON.parse(request.raw_post, symbolize_names: true)
rescue JSON::ParserError
render json: { error: "Invalid JSON" }, status: :bad_request
return
end
auth_result = authenticate_request(user, payload)
unless auth_result[:success]
render json: { error: auth_result[:error] }, status: :unauthorized
return
end
if auth_result[:pending_callback]
payload = merge_pending_callback_context(payload, auth_result[:pending_callback])
end
CallbackProcessorJob.perform_later(user.id, payload.deep_stringify_keys)
head :ok
end
|