0
0
Fork 0

Fix #2706 - Always respond with 200 to PuSH payloads (#2733)

Fix #2196 - Respond with 201 when Salmon accepted, 400 when unverified
Fix #2629 - Correctly handle confirm_domain? for local accounts
Unify rules for extracting author acct from XML, prefer <email>, fall back
to <name> + <uri> (see also #2017, #2172)
This commit is contained in:
Eugen Rochko 2017-05-03 17:02:18 +02:00 committed by GitHub
parent dd9d57300b
commit bafd22ecf4
9 changed files with 77 additions and 85 deletions

View file

@ -5,13 +5,13 @@ class Api::SalmonController < ApiController
respond_to :txt
def update
body = request.body.read
payload = request.body.read
if body.nil?
head 200
else
SalmonWorker.perform_async(@account.id, body.force_encoding('UTF-8'))
if !payload.nil? && verify?(payload)
SalmonWorker.perform_async(@account.id, payload.force_encoding('UTF-8'))
head 201
else
head 202
end
end
@ -20,4 +20,8 @@ class Api::SalmonController < ApiController
def set_account
@account = Account.find(params[:id])
end
def verify?(payload)
VerifySalmonService.new.call(payload)
end
end

View file

@ -19,10 +19,9 @@ class Api::SubscriptionsController < ApiController
if subscription.verify(body, request.headers['HTTP_X_HUB_SIGNATURE'])
ProcessingWorker.perform_async(@account.id, body.force_encoding('UTF-8'))
head 201
else
head 202
end
head 200
end
private