@@ -39,8 +39,6 @@ defmodule Pleroma.Web.OStatus do | |||||
{:ok, activities} | {:ok, activities} | ||||
end | end | ||||
# TODO | |||||
# wire up replies | |||||
def handle_note(entry, doc \\ nil) do | def handle_note(entry, doc \\ nil) do | ||||
content_html = string_from_xpath("/entry/content[1]", entry) | content_html = string_from_xpath("/entry/content[1]", entry) | ||||
@@ -112,7 +110,8 @@ defmodule Pleroma.Web.OStatus do | |||||
name: info.name, | name: info.name, | ||||
nickname: info.nickname <> "@" <> info.host, | nickname: info.nickname <> "@" <> info.host, | ||||
ap_id: info.uri, | ap_id: info.uri, | ||||
info: info | |||||
info: info, | |||||
avatar: info.avatar | |||||
} | } | ||||
# TODO: Make remote user changeset | # TODO: Make remote user changeset | ||||
# SHould enforce fqn nickname | # SHould enforce fqn nickname | ||||
@@ -121,9 +120,9 @@ defmodule Pleroma.Web.OStatus do | |||||
end | end | ||||
# TODO: Just takes the first one for now. | # TODO: Just takes the first one for now. | ||||
defp 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 | if href do | ||||
%{ | %{ | ||||
@@ -134,13 +134,15 @@ defmodule Pleroma.Web.Websub do | |||||
name = XML.string_from_xpath("/feed/author[1]/name", doc) | name = XML.string_from_xpath("/feed/author[1]/name", doc) | ||||
preferredUsername = XML.string_from_xpath("/feed/author[1]/poco:preferredUsername", doc) | preferredUsername = XML.string_from_xpath("/feed/author[1]/poco:preferredUsername", doc) | ||||
displayName = XML.string_from_xpath("/feed/author[1]/poco:displayName", doc) | displayName = XML.string_from_xpath("/feed/author[1]/poco:displayName", doc) | ||||
avatar = OStatus.make_avatar_object(doc) | |||||
{:ok, %{ | {:ok, %{ | ||||
uri: uri, | uri: uri, | ||||
hub: hub, | hub: hub, | ||||
nickname: preferredUsername || name, | nickname: preferredUsername || name, | ||||
name: displayName || name, | name: displayName || name, | ||||
host: URI.parse(uri).host | |||||
host: URI.parse(uri).host, | |||||
avatar: avatar | |||||
}} | }} | ||||
else e -> | else e -> | ||||
{:error, e} | {:error, e} | ||||
@@ -64,6 +64,7 @@ defmodule Pleroma.Web.OStatusTest do | |||||
assert user.local == false | assert user.local == false | ||||
assert user.info["uri"] == uri | assert user.info["uri"] == uri | ||||
assert user.ap_id == uri | assert user.ap_id == uri | ||||
assert user.avatar["type"] == "Image" | |||||
{:ok, user_again} = OStatus.find_or_make_user(uri) | {:ok, user_again} = OStatus.find_or_make_user(uri) | ||||
@@ -88,7 +89,8 @@ defmodule Pleroma.Web.OStatusTest do | |||||
topic: "https://social.heldscal.la/api/statuses/user_timeline/29191.atom", | topic: "https://social.heldscal.la/api/statuses/user_timeline/29191.atom", | ||||
uri: "https://social.heldscal.la/user/29191", | uri: "https://social.heldscal.la/user/29191", | ||||
host: "social.heldscal.la", | 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 | assert data == expected | ||||
end | end | ||||
@@ -109,7 +111,8 @@ defmodule Pleroma.Web.OStatusTest do | |||||
topic: "https://social.heldscal.la/api/statuses/user_timeline/29191.atom", | topic: "https://social.heldscal.la/api/statuses/user_timeline/29191.atom", | ||||
uri: "https://social.heldscal.la/user/29191", | uri: "https://social.heldscal.la/user/29191", | ||||
host: "social.heldscal.la", | 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 | assert data == expected | ||||
end | end | ||||
@@ -119,7 +119,8 @@ defmodule Pleroma.Web.WebsubTest do | |||||
uri: "https://mastodon.social/users/lambadalambda", | uri: "https://mastodon.social/users/lambadalambda", | ||||
nickname: "lambadalambda", | nickname: "lambadalambda", | ||||
name: "Critical Value", | 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 | assert expected == discovered | ||||