No-op for Salmons without body, fail fast if Webfinger does not contain
all required resource links (profile page, salmon, atom feed, magic key)
This commit is contained in:
		
							parent
							
								
									36e7eeb6b9
								
							
						
					
					
						commit
						157f03f8bd
					
				@ -3,9 +3,15 @@ class Api::SalmonController < ApiController
 | 
				
			|||||||
  respond_to :txt
 | 
					  respond_to :txt
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def update
 | 
					  def update
 | 
				
			||||||
    ProcessInteractionService.new.call(request.body.read, @account)
 | 
					    body = request.body.read
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if body.nil?
 | 
				
			||||||
 | 
					      head 200
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					      ProcessInteractionService.new.call(body, @account)
 | 
				
			||||||
      head 201
 | 
					      head 201
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private
 | 
					  private
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -23,6 +23,8 @@ class FollowRemoteAccountService < BaseService
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    data = Goldfinger.finger("acct:#{uri}")
 | 
					    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.remote_url  = data.link('http://schemas.google.com/g/2010#updates-from').href
 | 
				
			||||||
    account.salmon_url  = data.link('salmon').href
 | 
					    account.salmon_url  = data.link('salmon').href
 | 
				
			||||||
    account.url         = data.link('http://webfinger.net/rel/profile-page').href
 | 
					    account.url         = data.link('http://webfinger.net/rel/profile-page').href
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user