OStatus announce representer.
This commit is contained in:
parent
df71c142cf
commit
138641589d
2 changed files with 76 additions and 2 deletions
|
|
@ -2,7 +2,7 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do
|
|||
use Pleroma.DataCase
|
||||
|
||||
alias Pleroma.Web.OStatus.ActivityRepresenter
|
||||
alias Pleroma.{User, Activity}
|
||||
alias Pleroma.{User, Activity, Object}
|
||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||
|
||||
import Pleroma.Factory
|
||||
|
|
@ -73,6 +73,49 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do
|
|||
assert clean(res) == clean(expected)
|
||||
end
|
||||
|
||||
test "an announce activity" do
|
||||
note = insert(:note_activity)
|
||||
user = insert(:user)
|
||||
object = Object.get_cached_by_ap_id(note.data["object"]["id"])
|
||||
|
||||
{:ok, announce, object} = ActivityPub.announce(user, object)
|
||||
|
||||
announce = Repo.get(Activity, announce.id)
|
||||
|
||||
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)
|
||||
|> :xmerl.export_simple_content(:xmerl_xml)
|
||||
|> IO.iodata_to_binary
|
||||
|
||||
updated_at = announce.updated_at
|
||||
|> NaiveDateTime.to_iso8601
|
||||
inserted_at = announce.inserted_at
|
||||
|> NaiveDateTime.to_iso8601
|
||||
|
||||
expected = """
|
||||
<activity:verb>http://activitystrea.ms/schema/1.0/share</activity:verb>
|
||||
<id>#{announce.data["id"]}</id>
|
||||
<title>#{user.nickname} repeated a notice</title>
|
||||
<content type="html">RT #{note.data["object"]["content"]}</content>
|
||||
<published>#{inserted_at}</published>
|
||||
<updated>#{updated_at}</updated>
|
||||
<ostatus:conversation>#{announce.data["context"]}</ostatus:conversation>
|
||||
<link href="#{announce.data["context"]}" rel="ostatus:conversation" />
|
||||
<thr:in-reply-to ref="#{note.data["object"]["id"]}" />
|
||||
<activity:object>
|
||||
#{note_xml}
|
||||
</activity:object>
|
||||
<link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="#{note.data["actor"]}"/>
|
||||
"""
|
||||
|
||||
announce_xml = ActivityRepresenter.to_simple_form(announce, user)
|
||||
|> :xmerl.export_simple_content(:xmerl_xml)
|
||||
|> IO.iodata_to_binary
|
||||
|
||||
assert clean(expected) == clean(announce_xml)
|
||||
end
|
||||
|
||||
test "a like activity" do
|
||||
note = insert(:note)
|
||||
user = insert(:user)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue