]> cat aescling's git repositories - mastodon.git/commitdiff
No-op for Salmons without body, fail fast if Webfinger does not contain
authorEugen Rochko <eugen@zeonfederated.com>
Thu, 13 Oct 2016 11:41:06 +0000 (13:41 +0200)
committerEugen Rochko <eugen@zeonfederated.com>
Thu, 13 Oct 2016 11:41:06 +0000 (13:41 +0200)
all required resource links (profile page, salmon, atom feed, magic key)

app/controllers/api/salmon_controller.rb
app/services/follow_remote_account_service.rb

index 8bd653d7d942f74f73a13b2ae8c366b4a7706798..c0ba32ff29488d1cc65a3618de79ae8c78ce6748 100644 (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
index 43d3698e91365163dc37c25447003750e7d04c65..0a95badb2174c521d6a1b94e2a6ec95501a9ad73 100644 (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