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

@ -20,6 +20,8 @@ class ProcessFeedService < BaseService
end
class ProcessEntry
include AuthorExtractor
def call(xml, account)
@account = account
@xml = xml
@ -108,7 +110,7 @@ class ProcessFeedService < BaseService
# If that author cannot be found, don't record the status (do not misattribute)
if account?(entry)
begin
account = find_or_resolve_account(acct(entry))
account = author_from_xml(entry)
return [nil, false] if account.nil?
rescue Goldfinger::Error
return [nil, false]
@ -143,10 +145,6 @@ class ProcessFeedService < BaseService
[status, true]
end
def find_or_resolve_account(acct)
FollowRemoteAccountService.new.call(acct)
end
def find_or_resolve_status(parent, uri, url)
status = find_status(uri)
@ -275,13 +273,5 @@ class ProcessFeedService < BaseService
def account?(xml = @xml)
!xml.at_xpath('./xmlns:author', xmlns: TagManager::XMLNS).nil?
end
def acct(xml = @xml)
username = xml.at_xpath('./xmlns:author/xmlns:name', xmlns: TagManager::XMLNS).content
url = xml.at_xpath('./xmlns:author/xmlns:uri', xmlns: TagManager::XMLNS).content
domain = Addressable::URI.parse(url).normalize.host
"#{username}@#{domain}"
end
end
end