Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mastodon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pierre Boudes
mastodon
Commits
36e7eeb6
Commit
36e7eeb6
authored
8 years ago
by
Eugen Rochko
Browse files
Options
Downloads
Patches
Plain Diff
Treat dfrn:owner like xmlns:author for Friendica compatibility
parent
64302b3c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/services/follow_remote_account_service.rb
+25
-13
25 additions, 13 deletions
app/services/follow_remote_account_service.rb
with
25 additions
and
13 deletions
app/services/follow_remote_account_service.rb
+
25
−
13
View file @
36e7eeb6
class
FollowRemoteAccountService
<
BaseService
include
OStatus2
::
MagicKey
DFRN_NS
=
'http://purl.org/macgirvin/dfrn/1.0'
.
freeze
# Find or create a local account for a remote user.
# When creating, look up the user's webfinger and fetch all
# important information from their feed
...
...
@@ -27,21 +29,13 @@ class FollowRemoteAccountService < BaseService
account
.
public_key
=
magic_key_to_pem
(
data
.
link
(
'magic-public-key'
).
href
)
account
.
private_key
=
nil
feed
=
get_feed
(
account
.
remote_url
)
hubs
=
feed
.
xpath
(
'//xmlns:link[@rel="hub"]'
)
if
hubs
.
empty?
||
hubs
.
first
.
attribute
(
'href'
).
nil?
raise
Goldfinger
::
Error
,
'No PubSubHubbub hubs found'
end
if
feed
.
at_xpath
(
'/xmlns:feed/xmlns:author/xmlns:uri'
).
nil?
raise
Goldfinger
::
Error
,
'No author URI found'
end
xml
=
get_feed
(
account
.
remote_url
)
hubs
=
get_hubs
(
xml
)
account
.
uri
=
feed
.
at_xpath
(
'/xmlns:feed/xmlns:author/xmlns:uri'
).
content
account
.
uri
=
get_account_uri
(
xml
)
account
.
hub_url
=
hubs
.
first
.
attribute
(
'href'
).
value
get_profile
(
feed
,
account
)
get_profile
(
xml
,
account
)
account
.
save!
return
account
...
...
@@ -54,8 +48,26 @@ class FollowRemoteAccountService < BaseService
Nokogiri
::
XML
(
response
)
end
def
get_hubs
(
xml
)
hubs
=
xml
.
xpath
(
'//xmlns:link[@rel="hub"]'
)
raise
Goldfinger
::
Error
,
'No PubSubHubbub hubs found'
if
hubs
.
empty?
||
hubs
.
first
.
attribute
(
'href'
).
nil?
hubs
end
def
get_account_uri
(
xml
)
author_uri
=
xml
.
at_xpath
(
'/xmlns:feed/xmlns:author/xmlns:uri'
)
if
author_uri
.
nil?
owner
=
xml
.
at_xpath
(
'/xmlns:feed'
).
at_xpath
(
'./dfrn:owner'
,
dfrn:
DFRN_NS
)
author_uri
=
owner
.
at_xpath
(
'./xmlns:uri'
)
unless
owner
.
nil?
end
raise
Goldfinger
::
Error
,
'Author URI could not be found'
if
author_uri
.
nil?
author_uri
.
content
end
def
get_profile
(
xml
,
account
)
author
=
xml
.
at_xpath
(
'/xmlns:feed/xmlns:author'
)
author
=
xml
.
at_xpath
(
'/xmlns:feed/xmlns:author'
)
||
xml
.
at_xpath
(
'/xmlns:feed'
).
at_xpath
(
'./dfrn:owner'
,
dfrn:
DFRN_NS
)
update_remote_profile_service
.
call
(
author
,
account
)
end
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment