Format the code.
This commit is contained in:
parent
480932c8e5
commit
4afbef39f4
111 changed files with 4912 additions and 2769 deletions
|
|
@ -16,9 +16,12 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do
|
|||
|
||||
tuple = ActivityRepresenter.to_simple_form(activity, user)
|
||||
|
||||
res = :xmerl.export_simple_content(tuple, :xmerl_xml) |> IO.iodata_to_binary
|
||||
res = :xmerl.export_simple_content(tuple, :xmerl_xml) |> IO.iodata_to_binary()
|
||||
|
||||
assert String.contains?(res, ~s{<link type="text/html" href="https://mastodon.social/users/lambadalambda/updates/2314748" rel="alternate"/>})
|
||||
assert String.contains?(
|
||||
res,
|
||||
~s{<link type="text/html" href="https://mastodon.social/users/lambadalambda/updates/2314748" rel="alternate"/>}
|
||||
)
|
||||
end
|
||||
|
||||
test "a note activity" do
|
||||
|
|
@ -46,7 +49,7 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do
|
|||
|
||||
tuple = ActivityRepresenter.to_simple_form(note_activity, user)
|
||||
|
||||
res = :xmerl.export_simple_content(tuple, :xmerl_xml) |> IO.iodata_to_binary
|
||||
res = :xmerl.export_simple_content(tuple, :xmerl_xml) |> IO.iodata_to_binary()
|
||||
|
||||
assert clean(res) == clean(expected)
|
||||
end
|
||||
|
|
@ -61,7 +64,10 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do
|
|||
answer = %{answer | data: data}
|
||||
|
||||
note_object = Object.get_by_ap_id(note.data["object"]["id"])
|
||||
Repo.update!(Object.change(note_object, %{ data: Map.put(note_object.data, "external_url", "someurl") }))
|
||||
|
||||
Repo.update!(
|
||||
Object.change(note_object, %{data: Map.put(note_object.data, "external_url", "someurl")})
|
||||
)
|
||||
|
||||
user = User.get_cached_by_ap_id(answer.data["actor"])
|
||||
|
||||
|
|
@ -86,7 +92,7 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do
|
|||
|
||||
tuple = ActivityRepresenter.to_simple_form(answer, user)
|
||||
|
||||
res = :xmerl.export_simple_content(tuple, :xmerl_xml) |> IO.iodata_to_binary
|
||||
res = :xmerl.export_simple_content(tuple, :xmerl_xml) |> IO.iodata_to_binary()
|
||||
|
||||
assert clean(res) == clean(expected)
|
||||
end
|
||||
|
|
@ -102,9 +108,11 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do
|
|||
|
||||
note_user = User.get_cached_by_ap_id(note.data["actor"])
|
||||
note = Repo.get(Activity, note.id)
|
||||
note_xml = ActivityRepresenter.to_simple_form(note, note_user, true)
|
||||
|> :xmerl.export_simple_content(:xmerl_xml)
|
||||
|> to_string
|
||||
|
||||
note_xml =
|
||||
ActivityRepresenter.to_simple_form(note, note_user, true)
|
||||
|> :xmerl.export_simple_content(:xmerl_xml)
|
||||
|> to_string
|
||||
|
||||
expected = """
|
||||
<activity:object-type>http://activitystrea.ms/schema/1.0/activity</activity:object-type>
|
||||
|
|
@ -120,13 +128,16 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do
|
|||
<activity:object>
|
||||
#{note_xml}
|
||||
</activity:object>
|
||||
<link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="#{note.data["actor"]}"/>
|
||||
<link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="#{
|
||||
note.data["actor"]
|
||||
}"/>
|
||||
<link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/collection" href="http://activityschema.org/collection/public"/>
|
||||
"""
|
||||
|
||||
announce_xml = ActivityRepresenter.to_simple_form(announce, user)
|
||||
|> :xmerl.export_simple_content(:xmerl_xml)
|
||||
|> to_string
|
||||
announce_xml =
|
||||
ActivityRepresenter.to_simple_form(announce, user)
|
||||
|> :xmerl.export_simple_content(:xmerl_xml)
|
||||
|> to_string
|
||||
|
||||
assert clean(expected) == clean(announce_xml)
|
||||
end
|
||||
|
|
@ -139,7 +150,7 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do
|
|||
tuple = ActivityRepresenter.to_simple_form(like, user)
|
||||
refute is_nil(tuple)
|
||||
|
||||
res = :xmerl.export_simple_content(tuple, :xmerl_xml) |> IO.iodata_to_binary
|
||||
res = :xmerl.export_simple_content(tuple, :xmerl_xml) |> IO.iodata_to_binary()
|
||||
|
||||
expected = """
|
||||
<activity:verb>http://activitystrea.ms/schema/1.0/favorite</activity:verb>
|
||||
|
|
@ -156,7 +167,9 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do
|
|||
<link ref="#{like.data["context"]}" rel="ostatus:conversation" />
|
||||
<link rel="self" type="application/atom+xml" href="#{like.data["id"]}"/>
|
||||
<thr:in-reply-to ref="#{note.data["id"]}" />
|
||||
<link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="#{note.data["actor"]}"/>
|
||||
<link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="#{
|
||||
note.data["actor"]
|
||||
}"/>
|
||||
<link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/collection" href="http://activityschema.org/collection/public"/>
|
||||
"""
|
||||
|
||||
|
|
@ -166,18 +179,20 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do
|
|||
test "a follow activity" do
|
||||
follower = insert(:user)
|
||||
followed = insert(:user)
|
||||
{:ok, activity} = ActivityPub.insert(%{
|
||||
"type" => "Follow",
|
||||
"actor" => follower.ap_id,
|
||||
"object" => followed.ap_id,
|
||||
"to" => [followed.ap_id]
|
||||
})
|
||||
|
||||
{:ok, activity} =
|
||||
ActivityPub.insert(%{
|
||||
"type" => "Follow",
|
||||
"actor" => follower.ap_id,
|
||||
"object" => followed.ap_id,
|
||||
"to" => [followed.ap_id]
|
||||
})
|
||||
|
||||
tuple = ActivityRepresenter.to_simple_form(activity, follower)
|
||||
|
||||
refute is_nil(tuple)
|
||||
|
||||
res = :xmerl.export_simple_content(tuple, :xmerl_xml) |> IO.iodata_to_binary
|
||||
res = :xmerl.export_simple_content(tuple, :xmerl_xml) |> IO.iodata_to_binary()
|
||||
|
||||
expected = """
|
||||
<activity:object-type>http://activitystrea.ms/schema/1.0/activity</activity:object-type>
|
||||
|
|
@ -193,7 +208,9 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do
|
|||
<uri>#{activity.data["object"]}</uri>
|
||||
</activity:object>
|
||||
<link rel="self" type="application/atom+xml" href="#{activity.data["id"]}"/>
|
||||
<link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="#{activity.data["object"]}"/>
|
||||
<link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="#{
|
||||
activity.data["object"]
|
||||
}"/>
|
||||
"""
|
||||
|
||||
assert clean(res) == clean(expected)
|
||||
|
|
@ -209,7 +226,7 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do
|
|||
|
||||
refute is_nil(tuple)
|
||||
|
||||
res = :xmerl.export_simple_content(tuple, :xmerl_xml) |> IO.iodata_to_binary
|
||||
res = :xmerl.export_simple_content(tuple, :xmerl_xml) |> IO.iodata_to_binary()
|
||||
|
||||
expected = """
|
||||
<activity:object-type>http://activitystrea.ms/schema/1.0/activity</activity:object-type>
|
||||
|
|
@ -225,7 +242,9 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do
|
|||
<uri>#{followed.ap_id}</uri>
|
||||
</activity:object>
|
||||
<link rel="self" type="application/atom+xml" href="#{activity.data["id"]}"/>
|
||||
<link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="#{followed.ap_id}"/>
|
||||
<link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="#{
|
||||
followed.ap_id
|
||||
}"/>
|
||||
"""
|
||||
|
||||
assert clean(res) == clean(expected)
|
||||
|
|
@ -233,13 +252,22 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do
|
|||
|
||||
test "a delete" do
|
||||
user = insert(:user)
|
||||
activity = %Activity{data: %{ "id" => "ap_id", "type" => "Delete", "actor" => user.ap_id, "object" => "some_id", "published" => "2017-06-18T12:00:18+00:00" }}
|
||||
|
||||
activity = %Activity{
|
||||
data: %{
|
||||
"id" => "ap_id",
|
||||
"type" => "Delete",
|
||||
"actor" => user.ap_id,
|
||||
"object" => "some_id",
|
||||
"published" => "2017-06-18T12:00:18+00:00"
|
||||
}
|
||||
}
|
||||
|
||||
tuple = ActivityRepresenter.to_simple_form(activity, nil)
|
||||
|
||||
refute is_nil(tuple)
|
||||
|
||||
res = :xmerl.export_simple_content(tuple, :xmerl_xml) |> IO.iodata_to_binary
|
||||
res = :xmerl.export_simple_content(tuple, :xmerl_xml) |> IO.iodata_to_binary()
|
||||
|
||||
expected = """
|
||||
<activity:object-type>http://activitystrea.ms/schema/1.0/activity</activity:object-type>
|
||||
|
|
|
|||
|
|
@ -11,15 +11,19 @@ defmodule Pleroma.Web.OStatus.FeedRepresenterTest do
|
|||
|
||||
tuple = FeedRepresenter.to_simple_form(user, [note_activity], [user])
|
||||
|
||||
most_recent_update = note_activity.updated_at
|
||||
|> NaiveDateTime.to_iso8601
|
||||
most_recent_update =
|
||||
note_activity.updated_at
|
||||
|> NaiveDateTime.to_iso8601()
|
||||
|
||||
res = :xmerl.export_simple_content(tuple, :xmerl_xml) |> to_string
|
||||
user_xml = UserRepresenter.to_simple_form(user)
|
||||
|> :xmerl.export_simple_content(:xmerl_xml)
|
||||
|
||||
entry_xml = ActivityRepresenter.to_simple_form(note_activity, user)
|
||||
|> :xmerl.export_simple_content(:xmerl_xml)
|
||||
user_xml =
|
||||
UserRepresenter.to_simple_form(user)
|
||||
|> :xmerl.export_simple_content(:xmerl_xml)
|
||||
|
||||
entry_xml =
|
||||
ActivityRepresenter.to_simple_form(note_activity, user)
|
||||
|> :xmerl.export_simple_content(:xmerl_xml)
|
||||
|
||||
expected = """
|
||||
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:activity="http://activitystrea.ms/spec/1.0/" xmlns:poco="http://portablecontacts.net/spec/1.0" xmlns:ostatus="http://ostatus.org/schema/1.0">
|
||||
|
|
@ -39,6 +43,7 @@ defmodule Pleroma.Web.OStatus.FeedRepresenterTest do
|
|||
</entry>
|
||||
</feed>
|
||||
"""
|
||||
|
||||
assert clean(res) == clean(expected)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -14,8 +14,13 @@ defmodule Pleroma.Web.OStatus.DeleteHandlingTest do
|
|||
|
||||
{:ok, like, _object} = Pleroma.Web.ActivityPub.ActivityPub.like(user, object)
|
||||
|
||||
incoming = File.read!("test/fixtures/delete.xml")
|
||||
|> String.replace("tag:mastodon.sdf.org,2017-06-10:objectId=310513:objectType=Status", note.data["object"]["id"])
|
||||
incoming =
|
||||
File.read!("test/fixtures/delete.xml")
|
||||
|> String.replace(
|
||||
"tag:mastodon.sdf.org,2017-06-10:objectId=310513:objectType=Status",
|
||||
note.data["object"]["id"]
|
||||
)
|
||||
|
||||
{:ok, [delete]} = OStatus.handle_incoming(incoming)
|
||||
|
||||
refute Repo.get(Activity, note.id)
|
||||
|
|
|
|||
|
|
@ -7,9 +7,11 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
|
|||
test "decodes a salmon", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
salmon = File.read!("test/fixtures/salmon.xml")
|
||||
conn = conn
|
||||
|> put_req_header("content-type", "application/atom+xml")
|
||||
|> post("/users/#{user.nickname}/salmon", salmon)
|
||||
|
||||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/atom+xml")
|
||||
|> post("/users/#{user.nickname}/salmon", salmon)
|
||||
|
||||
assert response(conn, 200)
|
||||
end
|
||||
|
|
@ -17,21 +19,30 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
|
|||
test "decodes a salmon with a changed magic key", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
salmon = File.read!("test/fixtures/salmon.xml")
|
||||
conn = conn
|
||||
|> put_req_header("content-type", "application/atom+xml")
|
||||
|> post("/users/#{user.nickname}/salmon", salmon)
|
||||
|
||||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/atom+xml")
|
||||
|> post("/users/#{user.nickname}/salmon", salmon)
|
||||
|
||||
assert response(conn, 200)
|
||||
|
||||
# Set a wrong magic-key for a user so it has to refetch
|
||||
salmon_user = User.get_by_ap_id("http://gs.example.org:4040/index.php/user/1")
|
||||
info = salmon_user.info
|
||||
|> Map.put("magic_key", "RSA.pu0s-halox4tu7wmES1FVSx6u-4wc0YrUFXcqWXZG4-27UmbCOpMQftRCldNRfyA-qLbz-eqiwrong1EwUvjsD4cYbAHNGHwTvDOyx5AKthQUP44ykPv7kjKGh3DWKySJvcs9tlUG87hlo7AvnMo9pwRS_Zz2CacQ-MKaXyDepk=.AQAB") # Wrong key
|
||||
# Wrong key
|
||||
info =
|
||||
salmon_user.info
|
||||
|> Map.put(
|
||||
"magic_key",
|
||||
"RSA.pu0s-halox4tu7wmES1FVSx6u-4wc0YrUFXcqWXZG4-27UmbCOpMQftRCldNRfyA-qLbz-eqiwrong1EwUvjsD4cYbAHNGHwTvDOyx5AKthQUP44ykPv7kjKGh3DWKySJvcs9tlUG87hlo7AvnMo9pwRS_Zz2CacQ-MKaXyDepk=.AQAB"
|
||||
)
|
||||
|
||||
Repo.update(User.info_changeset(salmon_user, %{info: info}))
|
||||
|
||||
conn = build_conn()
|
||||
|> put_req_header("content-type", "application/atom+xml")
|
||||
|> post("/users/#{user.nickname}/salmon", salmon)
|
||||
conn =
|
||||
build_conn()
|
||||
|> put_req_header("content-type", "application/atom+xml")
|
||||
|> post("/users/#{user.nickname}/salmon", salmon)
|
||||
|
||||
assert response(conn, 200)
|
||||
end
|
||||
|
|
@ -40,8 +51,9 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
|
|||
note_activity = insert(:note_activity)
|
||||
user = User.get_cached_by_ap_id(note_activity.data["actor"])
|
||||
|
||||
conn = conn
|
||||
|> get("/users/#{user.nickname}/feed.atom")
|
||||
conn =
|
||||
conn
|
||||
|> get("/users/#{user.nickname}/feed.atom")
|
||||
|
||||
assert response(conn, 200) =~ note_activity.data["object"]["content"]
|
||||
end
|
||||
|
|
@ -49,27 +61,30 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
|
|||
test "gets an object", %{conn: conn} do
|
||||
note_activity = insert(:note_activity)
|
||||
user = User.get_by_ap_id(note_activity.data["actor"])
|
||||
[_, uuid] = hd Regex.scan(~r/.+\/([\w-]+)$/, note_activity.data["object"]["id"])
|
||||
[_, uuid] = hd(Regex.scan(~r/.+\/([\w-]+)$/, note_activity.data["object"]["id"]))
|
||||
url = "/objects/#{uuid}"
|
||||
|
||||
conn = conn
|
||||
|> get(url)
|
||||
conn =
|
||||
conn
|
||||
|> get(url)
|
||||
|
||||
expected = ActivityRepresenter.to_simple_form(note_activity, user, true)
|
||||
|> ActivityRepresenter.wrap_with_entry
|
||||
|> :xmerl.export_simple(:xmerl_xml)
|
||||
|> to_string
|
||||
expected =
|
||||
ActivityRepresenter.to_simple_form(note_activity, user, true)
|
||||
|> ActivityRepresenter.wrap_with_entry()
|
||||
|> :xmerl.export_simple(:xmerl_xml)
|
||||
|> to_string
|
||||
|
||||
assert response(conn, 200) == expected
|
||||
end
|
||||
|
||||
test "gets an activity", %{conn: conn} do
|
||||
note_activity = insert(:note_activity)
|
||||
[_, uuid] = hd Regex.scan(~r/.+\/([\w-]+)$/, note_activity.data["id"])
|
||||
[_, uuid] = hd(Regex.scan(~r/.+\/([\w-]+)$/, note_activity.data["id"]))
|
||||
url = "/activities/#{uuid}"
|
||||
|
||||
conn = conn
|
||||
|> get(url)
|
||||
conn =
|
||||
conn
|
||||
|> get(url)
|
||||
|
||||
assert response(conn, 200)
|
||||
end
|
||||
|
|
@ -78,8 +93,9 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
|
|||
note_activity = insert(:note_activity)
|
||||
url = "/notice/#{note_activity.id}"
|
||||
|
||||
conn = conn
|
||||
|> get(url)
|
||||
conn =
|
||||
conn
|
||||
|> get(url)
|
||||
|
||||
assert response(conn, 200)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -20,12 +20,18 @@ defmodule Pleroma.Web.OStatusTest do
|
|||
assert user.info["note_count"] == 1
|
||||
assert activity.data["type"] == "Create"
|
||||
assert activity.data["object"]["type"] == "Note"
|
||||
assert activity.data["object"]["id"] == "tag:gs.example.org:4040,2017-04-23:noticeId=29:objectType=note"
|
||||
|
||||
assert activity.data["object"]["id"] ==
|
||||
"tag:gs.example.org:4040,2017-04-23:noticeId=29:objectType=note"
|
||||
|
||||
assert activity.data["published"] == "2017-04-23T14:51:03+00:00"
|
||||
assert activity.data["object"]["published"] == "2017-04-23T14:51:03+00:00"
|
||||
assert activity.data["context"] == "tag:gs.example.org:4040,2017-04-23:objectType=thread:nonce=f09e22f58abd5c7b"
|
||||
|
||||
assert activity.data["context"] ==
|
||||
"tag:gs.example.org:4040,2017-04-23:objectType=thread:nonce=f09e22f58abd5c7b"
|
||||
|
||||
assert "http://pleroma.example.org:4000/users/lain3" in activity.data["to"]
|
||||
assert activity.data["object"]["emoji"] == %{ "marko" => "marko.png", "reimu" => "reimu.png" }
|
||||
assert activity.data["object"]["emoji"] == %{"marko" => "marko.png", "reimu" => "reimu.png"}
|
||||
assert activity.local == false
|
||||
end
|
||||
|
||||
|
|
@ -65,10 +71,12 @@ defmodule Pleroma.Web.OStatusTest do
|
|||
test "handle incoming notes - Mastodon, salmon, reply" do
|
||||
# It uses the context of the replied to object
|
||||
Repo.insert!(%Object{
|
||||
data: %{
|
||||
"id" => "https://pleroma.soykaf.com/objects/c237d966-ac75-4fe3-a87a-d89d71a3a7a4",
|
||||
"context" => "2hu"
|
||||
}})
|
||||
data: %{
|
||||
"id" => "https://pleroma.soykaf.com/objects/c237d966-ac75-4fe3-a87a-d89d71a3a7a4",
|
||||
"context" => "2hu"
|
||||
}
|
||||
})
|
||||
|
||||
incoming = File.read!("test/fixtures/incoming_reply_mastodon.xml")
|
||||
{:ok, [activity]} = OStatus.handle_incoming(incoming)
|
||||
|
||||
|
|
@ -113,8 +121,13 @@ defmodule Pleroma.Web.OStatusTest do
|
|||
assert activity.data["type"] == "Create"
|
||||
assert activity.data["object"]["type"] == "Note"
|
||||
assert activity.data["object"]["actor"] == "https://social.heldscal.la/user/23211"
|
||||
assert activity.data["object"]["content"] == "@<a href=\"https://gs.archae.me/user/4687\" class=\"h-card u-url p-nickname mention\" title=\"shpbot\">shpbot</a> why not indeed."
|
||||
assert activity.data["object"]["inReplyTo"] == "tag:gs.archae.me,2017-04-30:noticeId=778260:objectType=note"
|
||||
|
||||
assert activity.data["object"]["content"] ==
|
||||
"@<a href=\"https://gs.archae.me/user/4687\" class=\"h-card u-url p-nickname mention\" title=\"shpbot\">shpbot</a> why not indeed."
|
||||
|
||||
assert activity.data["object"]["inReplyTo"] ==
|
||||
"tag:gs.archae.me,2017-04-30:noticeId=778260:objectType=note"
|
||||
|
||||
assert "https://www.w3.org/ns/activitystreams#Public" in activity.data["to"]
|
||||
end
|
||||
|
||||
|
|
@ -141,9 +154,11 @@ defmodule Pleroma.Web.OStatusTest do
|
|||
incoming = File.read!("test/fixtures/share-gs-local.xml")
|
||||
note_activity = insert(:note_activity)
|
||||
user = User.get_cached_by_ap_id(note_activity.data["actor"])
|
||||
incoming = incoming
|
||||
|> String.replace("LOCAL_ID", note_activity.data["object"]["id"])
|
||||
|> String.replace("LOCAL_USER", user.ap_id)
|
||||
|
||||
incoming =
|
||||
incoming
|
||||
|> String.replace("LOCAL_ID", note_activity.data["object"]["id"])
|
||||
|> String.replace("LOCAL_USER", user.ap_id)
|
||||
|
||||
{:ok, [[activity, retweeted_activity]]} = OStatus.handle_incoming(incoming)
|
||||
|
||||
|
|
@ -168,7 +183,9 @@ defmodule Pleroma.Web.OStatusTest do
|
|||
assert activity.data["type"] == "Announce"
|
||||
assert activity.data["actor"] == "https://mastodon.social/users/lambadalambda"
|
||||
assert activity.data["object"] == retweeted_activity.data["object"]["id"]
|
||||
assert activity.data["id"] == "tag:mastodon.social,2017-05-03:objectId=4934452:objectType=Status"
|
||||
|
||||
assert activity.data["id"] ==
|
||||
"tag:mastodon.social,2017-05-03:objectId=4934452:objectType=Status"
|
||||
|
||||
refute activity.local
|
||||
assert retweeted_activity.data["type"] == "Create"
|
||||
|
|
@ -178,35 +195,42 @@ defmodule Pleroma.Web.OStatusTest do
|
|||
end
|
||||
|
||||
test "handle incoming favorites - GS, websub" do
|
||||
capture_log fn ->
|
||||
capture_log(fn ->
|
||||
incoming = File.read!("test/fixtures/favorite.xml")
|
||||
{:ok, [[activity, favorited_activity]]} = OStatus.handle_incoming(incoming)
|
||||
|
||||
assert activity.data["type"] == "Like"
|
||||
assert activity.data["actor"] == "https://social.heldscal.la/user/23211"
|
||||
assert activity.data["object"] == favorited_activity.data["object"]["id"]
|
||||
assert activity.data["id"] == "tag:social.heldscal.la,2017-05-05:fave:23211:comment:2061643:2017-05-05T09:12:50+00:00"
|
||||
|
||||
assert activity.data["id"] ==
|
||||
"tag:social.heldscal.la,2017-05-05:fave:23211:comment:2061643:2017-05-05T09:12:50+00:00"
|
||||
|
||||
refute activity.local
|
||||
assert favorited_activity.data["type"] == "Create"
|
||||
assert favorited_activity.data["actor"] == "https://shitposter.club/user/1"
|
||||
assert favorited_activity.data["object"]["id"] == "tag:shitposter.club,2017-05-05:noticeId=2827873:objectType=comment"
|
||||
|
||||
assert favorited_activity.data["object"]["id"] ==
|
||||
"tag:shitposter.club,2017-05-05:noticeId=2827873:objectType=comment"
|
||||
|
||||
refute favorited_activity.local
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
test "handle conversation references" do
|
||||
incoming = File.read!("test/fixtures/mastodon_conversation.xml")
|
||||
{:ok, [activity]} = OStatus.handle_incoming(incoming)
|
||||
|
||||
assert activity.data["context"] == "tag:mastodon.social,2017-08-28:objectId=7876885:objectType=Conversation"
|
||||
assert activity.data["context"] ==
|
||||
"tag:mastodon.social,2017-08-28:objectId=7876885:objectType=Conversation"
|
||||
end
|
||||
|
||||
test "handle incoming favorites with locally available object - GS, websub" do
|
||||
note_activity = insert(:note_activity)
|
||||
|
||||
incoming = File.read!("test/fixtures/favorite_with_local_note.xml")
|
||||
|> String.replace("localid", note_activity.data["object"]["id"])
|
||||
incoming =
|
||||
File.read!("test/fixtures/favorite_with_local_note.xml")
|
||||
|> String.replace("localid", note_activity.data["object"]["id"])
|
||||
|
||||
{:ok, [[activity, favorited_activity]]} = OStatus.handle_incoming(incoming)
|
||||
|
||||
|
|
@ -224,9 +248,15 @@ defmodule Pleroma.Web.OStatusTest do
|
|||
|
||||
assert activity.data["type"] == "Create"
|
||||
assert activity.data["object"]["type"] == "Note"
|
||||
assert activity.data["object"]["inReplyTo"] == "http://pleroma.example.org:4000/objects/55bce8fc-b423-46b1-af71-3759ab4670bc"
|
||||
|
||||
assert activity.data["object"]["inReplyTo"] ==
|
||||
"http://pleroma.example.org:4000/objects/55bce8fc-b423-46b1-af71-3759ab4670bc"
|
||||
|
||||
assert "http://pleroma.example.org:4000/users/lain5" in activity.data["to"]
|
||||
assert activity.data["object"]["id"] == "tag:gs.example.org:4040,2017-04-25:noticeId=55:objectType=note"
|
||||
|
||||
assert activity.data["object"]["id"] ==
|
||||
"tag:gs.example.org:4040,2017-04-25:noticeId=55:objectType=note"
|
||||
|
||||
assert "https://www.w3.org/ns/activitystreams#Public" in activity.data["to"]
|
||||
end
|
||||
|
||||
|
|
@ -234,7 +264,10 @@ defmodule Pleroma.Web.OStatusTest do
|
|||
incoming = File.read!("test/fixtures/follow.xml")
|
||||
{:ok, [activity]} = OStatus.handle_incoming(incoming)
|
||||
assert activity.data["type"] == "Follow"
|
||||
assert activity.data["id"] == "tag:social.heldscal.la,2017-05-07:subscription:23211:person:44803:2017-05-07T09:54:48+00:00"
|
||||
|
||||
assert activity.data["id"] ==
|
||||
"tag:social.heldscal.la,2017-05-07:subscription:23211:person:44803:2017-05-07T09:54:48+00:00"
|
||||
|
||||
assert activity.data["actor"] == "https://social.heldscal.la/user/23211"
|
||||
assert activity.data["object"] == "https://pawoo.net/users/pekorino"
|
||||
refute activity.local
|
||||
|
|
@ -304,7 +337,8 @@ defmodule Pleroma.Web.OStatusTest do
|
|||
|
||||
expected = %{
|
||||
"hub" => "https://social.heldscal.la/main/push/hub",
|
||||
"magic_key" => "RSA.wQ3i9UA0qmAxZ0WTIp4a-waZn_17Ez1pEEmqmqoooRsG1_BvpmOvLN0G2tEcWWxl2KOtdQMCiPptmQObeZeuj48mdsDZ4ArQinexY2hCCTcbV8Xpswpkb8K05RcKipdg07pnI7tAgQ0VWSZDImncL6YUGlG5YN8b5TjGOwk2VG8=.AQAB",
|
||||
"magic_key" =>
|
||||
"RSA.wQ3i9UA0qmAxZ0WTIp4a-waZn_17Ez1pEEmqmqoooRsG1_BvpmOvLN0G2tEcWWxl2KOtdQMCiPptmQObeZeuj48mdsDZ4ArQinexY2hCCTcbV8Xpswpkb8K05RcKipdg07pnI7tAgQ0VWSZDImncL6YUGlG5YN8b5TjGOwk2VG8=.AQAB",
|
||||
"name" => "shp",
|
||||
"nickname" => "shp",
|
||||
"salmon" => "https://social.heldscal.la/main/salmon/user/29191",
|
||||
|
|
@ -314,10 +348,20 @@ defmodule Pleroma.Web.OStatusTest do
|
|||
"host" => "social.heldscal.la",
|
||||
"fqn" => user,
|
||||
"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}",
|
||||
"ap_id" => nil
|
||||
}
|
||||
|
||||
assert data == expected
|
||||
end
|
||||
|
||||
|
|
@ -329,7 +373,8 @@ defmodule Pleroma.Web.OStatusTest do
|
|||
|
||||
expected = %{
|
||||
"hub" => "https://social.heldscal.la/main/push/hub",
|
||||
"magic_key" => "RSA.wQ3i9UA0qmAxZ0WTIp4a-waZn_17Ez1pEEmqmqoooRsG1_BvpmOvLN0G2tEcWWxl2KOtdQMCiPptmQObeZeuj48mdsDZ4ArQinexY2hCCTcbV8Xpswpkb8K05RcKipdg07pnI7tAgQ0VWSZDImncL6YUGlG5YN8b5TjGOwk2VG8=.AQAB",
|
||||
"magic_key" =>
|
||||
"RSA.wQ3i9UA0qmAxZ0WTIp4a-waZn_17Ez1pEEmqmqoooRsG1_BvpmOvLN0G2tEcWWxl2KOtdQMCiPptmQObeZeuj48mdsDZ4ArQinexY2hCCTcbV8Xpswpkb8K05RcKipdg07pnI7tAgQ0VWSZDImncL6YUGlG5YN8b5TjGOwk2VG8=.AQAB",
|
||||
"name" => "shp",
|
||||
"nickname" => "shp",
|
||||
"salmon" => "https://social.heldscal.la/main/salmon/user/29191",
|
||||
|
|
@ -339,28 +384,40 @@ defmodule Pleroma.Web.OStatusTest do
|
|||
"host" => "social.heldscal.la",
|
||||
"fqn" => user,
|
||||
"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}",
|
||||
"ap_id" => nil
|
||||
}
|
||||
|
||||
assert data == expected
|
||||
end
|
||||
end
|
||||
|
||||
describe "fetching a status by it's HTML url" do
|
||||
test "it builds a missing status from an html url" do
|
||||
capture_log fn ->
|
||||
capture_log(fn ->
|
||||
url = "https://shitposter.club/notice/2827873"
|
||||
{:ok, [activity] } = OStatus.fetch_activity_from_url(url)
|
||||
{:ok, [activity]} = OStatus.fetch_activity_from_url(url)
|
||||
|
||||
assert activity.data["actor"] == "https://shitposter.club/user/1"
|
||||
assert activity.data["object"]["id"] == "tag:shitposter.club,2017-05-05:noticeId=2827873:objectType=comment"
|
||||
end
|
||||
|
||||
assert activity.data["object"]["id"] ==
|
||||
"tag:shitposter.club,2017-05-05:noticeId=2827873:objectType=comment"
|
||||
end)
|
||||
end
|
||||
|
||||
test "it works for atom notes, too" do
|
||||
url = "https://social.sakamoto.gq/objects/0ccc1a2c-66b0-4305-b23a-7f7f2b040056"
|
||||
{:ok, [activity] } = OStatus.fetch_activity_from_url(url)
|
||||
{:ok, [activity]} = OStatus.fetch_activity_from_url(url)
|
||||
assert activity.data["actor"] == "https://social.sakamoto.gq/users/eal"
|
||||
assert activity.data["object"]["id"] == url
|
||||
end
|
||||
|
|
@ -370,6 +427,9 @@ defmodule Pleroma.Web.OStatusTest do
|
|||
incoming = File.read!("test/fixtures/nil_mention_entry.xml")
|
||||
{:ok, [activity]} = OStatus.handle_incoming(incoming)
|
||||
|
||||
assert activity.data["to"] == ["http://localhost:4001/users/atarifrosch@social.stopwatchingus-heidelberg.de/followers", "https://www.w3.org/ns/activitystreams#Public"]
|
||||
assert activity.data["to"] == [
|
||||
"http://localhost:4001/users/atarifrosch@social.stopwatchingus-heidelberg.de/followers",
|
||||
"https://www.w3.org/ns/activitystreams#Public"
|
||||
]
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue