forked from mirrors/akkoma
Pleroma AP detection mechanism.
This commit is contained in:
parent
9a4d400ff4
commit
fb02300234
|
@ -177,6 +177,13 @@ def get_tags(entry) do
|
||||||
end
|
end
|
||||||
|
|
||||||
def maybe_update(doc, user) do
|
def maybe_update(doc, user) do
|
||||||
|
if "true" == string_from_xpath("//author[1]/ap_enabled", doc) do
|
||||||
|
Transmogrifier.upgrade_user_from_ap_id(user.ap_id)
|
||||||
|
else
|
||||||
|
maybe_update_ostatus(doc, user)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def maybe_update_ostatus(doc, user) do
|
||||||
old_data = %{
|
old_data = %{
|
||||||
avatar: user.avatar,
|
avatar: user.avatar,
|
||||||
bio: user.bio,
|
bio: user.bio,
|
||||||
|
|
|
@ -12,6 +12,12 @@ def to_simple_form(user) do
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
ap_enabled = if user.local do
|
||||||
|
[{:ap_enabled, ['true']}]
|
||||||
|
else
|
||||||
|
[]
|
||||||
|
end
|
||||||
|
|
||||||
[
|
[
|
||||||
{:id, [ap_id]},
|
{:id, [ap_id]},
|
||||||
{:"activity:object", ['http://activitystrea.ms/schema/1.0/person']},
|
{:"activity:object", ['http://activitystrea.ms/schema/1.0/person']},
|
||||||
|
@ -22,6 +28,6 @@ def to_simple_form(user) do
|
||||||
{:summary, [bio]},
|
{:summary, [bio]},
|
||||||
{:name, [nickname]},
|
{:name, [nickname]},
|
||||||
{:link, [rel: 'avatar', href: avatar_url], []}
|
{:link, [rel: 'avatar', href: avatar_url], []}
|
||||||
] ++ banner
|
] ++ banner ++ ap_enabled
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -306,7 +306,8 @@ test "it returns user info in a hash" do
|
||||||
"fqn" => user,
|
"fqn" => user,
|
||||||
"bio" => "cofe",
|
"bio" => "cofe",
|
||||||
"avatar" => %{"type" => "Image", "url" => [%{"href" => "https://social.heldscal.la/avatar/29191-original-20170421154949.jpeg", "mediaType" => "image/jpeg", "type" => "Link"}]},
|
"avatar" => %{"type" => "Image", "url" => [%{"href" => "https://social.heldscal.la/avatar/29191-original-20170421154949.jpeg", "mediaType" => "image/jpeg", "type" => "Link"}]},
|
||||||
"subscribe_address" => "https://social.heldscal.la/main/ostatussub?profile={uri}"
|
"subscribe_address" => "https://social.heldscal.la/main/ostatussub?profile={uri}",
|
||||||
|
"ap_id" => nil
|
||||||
}
|
}
|
||||||
assert data == expected
|
assert data == expected
|
||||||
end
|
end
|
||||||
|
@ -330,7 +331,8 @@ test "it works with the uri" do
|
||||||
"fqn" => user,
|
"fqn" => user,
|
||||||
"bio" => "cofe",
|
"bio" => "cofe",
|
||||||
"avatar" => %{"type" => "Image", "url" => [%{"href" => "https://social.heldscal.la/avatar/29191-original-20170421154949.jpeg", "mediaType" => "image/jpeg", "type" => "Link"}]},
|
"avatar" => %{"type" => "Image", "url" => [%{"href" => "https://social.heldscal.la/avatar/29191-original-20170421154949.jpeg", "mediaType" => "image/jpeg", "type" => "Link"}]},
|
||||||
"subscribe_address" => "https://social.heldscal.la/main/ostatussub?profile={uri}"
|
"subscribe_address" => "https://social.heldscal.la/main/ostatussub?profile={uri}",
|
||||||
|
"ap_id" => nil
|
||||||
}
|
}
|
||||||
assert data == expected
|
assert data == expected
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,6 +22,7 @@ test "returns a user with id, uri, name and link" do
|
||||||
<name>#{user.nickname}</name>
|
<name>#{user.nickname}</name>
|
||||||
<link rel="avatar" href="#{User.avatar_url(user)}" />
|
<link rel="avatar" href="#{User.avatar_url(user)}" />
|
||||||
<link rel="header" href="#{User.banner_url(user)}" />
|
<link rel="header" href="#{User.banner_url(user)}" />
|
||||||
|
<ap_enabled>true</ap_enabled>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
assert clean(res) == clean(expected)
|
assert clean(res) == clean(expected)
|
||||||
|
|
Loading…
Reference in a new issue