Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pleroma
pleroma
Commits
f9912599
Commit
f9912599
authored
Apr 30, 2017
by
lain
Browse files
Pull in remote avatar on federation.
parent
18edc299
Changes
4
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/web/ostatus/ostatus.ex
View file @
f9912599
...
...
@@ -39,8 +39,6 @@ def handle_incoming(xml_string) do
{
:ok
,
activities
}
end
# TODO
# wire up replies
def
handle_note
(
entry
,
doc
\\
nil
)
do
content_html
=
string_from_xpath
(
"/entry/content[1]"
,
entry
)
...
...
@@ -112,7 +110,8 @@ def make_user(uri) do
name:
info
.
name
,
nickname:
info
.
nickname
<>
"@"
<>
info
.
host
,
ap_id:
info
.
uri
,
info:
info
info:
info
,
avatar:
info
.
avatar
}
# TODO: Make remote user changeset
# SHould enforce fqn nickname
...
...
@@ -121,9 +120,9 @@ def make_user(uri) do
end
# TODO: Just takes the first one for now.
def
p
make_avatar_object
(
author_doc
)
do
href
=
string_from_xpath
(
"/author[1]/link[@rel=
\"
avatar
\"
]/@href"
,
author_doc
)
type
=
string_from_xpath
(
"/author[1]/link[@rel=
\"
avatar
\"
]/@type"
,
author_doc
)
def
make_avatar_object
(
author_doc
)
do
href
=
string_from_xpath
(
"/
feed/
author[1]/link[@rel=
\"
avatar
\"
]/@href"
,
author_doc
)
type
=
string_from_xpath
(
"/
feed/
author[1]/link[@rel=
\"
avatar
\"
]/@type"
,
author_doc
)
if
href
do
%{
...
...
lib/pleroma/web/websub/websub.ex
View file @
f9912599
...
...
@@ -134,13 +134,15 @@ def gather_feed_data(topic, getter \\ &HTTPoison.get/1) do
name
=
XML
.
string_from_xpath
(
"/feed/author[1]/name"
,
doc
)
preferredUsername
=
XML
.
string_from_xpath
(
"/feed/author[1]/poco:preferredUsername"
,
doc
)
displayName
=
XML
.
string_from_xpath
(
"/feed/author[1]/poco:displayName"
,
doc
)
avatar
=
OStatus
.
make_avatar_object
(
doc
)
{
:ok
,
%{
uri:
uri
,
hub:
hub
,
nickname:
preferredUsername
||
name
,
name:
displayName
||
name
,
host:
URI
.
parse
(
uri
)
.
host
host:
URI
.
parse
(
uri
)
.
host
,
avatar:
avatar
}}
else
e
->
{
:error
,
e
}
...
...
test/web/ostatus/ostatus_test.exs
View file @
f9912599
...
...
@@ -64,6 +64,7 @@ test "tries to use the information in poco fields" do
assert
user
.
local
==
false
assert
user
.
info
[
"uri"
]
==
uri
assert
user
.
ap_id
==
uri
assert
user
.
avatar
[
"type"
]
==
"Image"
{
:ok
,
user_again
}
=
OStatus
.
find_or_make_user
(
uri
)
...
...
@@ -88,7 +89,8 @@ test "it returns user info in a hash" do
topic:
"https://social.heldscal.la/api/statuses/user_timeline/29191.atom"
,
uri:
"https://social.heldscal.la/user/29191"
,
host:
"social.heldscal.la"
,
fqn:
user
fqn:
user
,
avatar:
%{
"type"
=>
"Image"
,
"url"
=>
[%{
"href"
=>
"https://social.heldscal.la/avatar/29191-original-20170421154949.jpeg"
,
"mediaType"
=>
"image/jpeg"
,
"type"
=>
"Link"
}]}
}
assert
data
==
expected
end
...
...
@@ -109,7 +111,8 @@ test "it works with the uri" do
topic:
"https://social.heldscal.la/api/statuses/user_timeline/29191.atom"
,
uri:
"https://social.heldscal.la/user/29191"
,
host:
"social.heldscal.la"
,
fqn:
user
fqn:
user
,
avatar:
%{
"type"
=>
"Image"
,
"url"
=>
[%{
"href"
=>
"https://social.heldscal.la/avatar/29191-original-20170421154949.jpeg"
,
"mediaType"
=>
"image/jpeg"
,
"type"
=>
"Link"
}]}
}
assert
data
==
expected
end
...
...
test/web/websub/websub_test.exs
View file @
f9912599
...
...
@@ -119,7 +119,8 @@ test "discovers the hub and canonical url" do
uri:
"https://mastodon.social/users/lambadalambda"
,
nickname:
"lambadalambda"
,
name:
"Critical Value"
,
host:
"mastodon.social"
host:
"mastodon.social"
,
avatar:
%{
"type"
=>
"Image"
,
"url"
=>
[%{
"href"
=>
"https://files.mastodon.social/accounts/avatars/000/000/264/original/1429214160519.gif?1492379244"
,
"mediaType"
=>
"image/gif"
,
"type"
=>
"Link"
}]}
}
assert
expected
==
discovered
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment