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
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
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"])
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
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>
<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
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>
<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"/>
"""
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>
<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)
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>
<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)
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>