Browse Source

No-op for Salmons without body, fail fast if Webfinger does not contain

all required resource links (profile page, salmon, atom feed, magic key)
closed-social-glitch-2
Eugen Rochko 7 years ago
parent
commit
157f03f8bd
2 changed files with 10 additions and 2 deletions
  1. +8
    -2
      app/controllers/api/salmon_controller.rb
  2. +2
    -0
      app/services/follow_remote_account_service.rb

+ 8
- 2
app/controllers/api/salmon_controller.rb View File

@ -3,8 +3,14 @@ class Api::SalmonController < ApiController
respond_to :txt
def update
ProcessInteractionService.new.call(request.body.read, @account)
head 201
body = request.body.read
if body.nil?
head 200
else
ProcessInteractionService.new.call(body, @account)
head 201
end
end
private

+ 2
- 0
app/services/follow_remote_account_service.rb View File

@ -23,6 +23,8 @@ class FollowRemoteAccountService < BaseService
data = Goldfinger.finger("acct:#{uri}")
raise Goldfinger::Error, 'Missing resource links' if data.link('http://schemas.google.com/g/2010#updates-from').nil? || data.link('salmon').nil? || data.link('http://webfinger.net/rel/profile-page').nil? || data.link('magic-public-key').nil?
account.remote_url = data.link('http://schemas.google.com/g/2010#updates-from').href
account.salmon_url = data.link('salmon').href
account.url = data.link('http://webfinger.net/rel/profile-page').href

Loading…
Cancel
Save