Add TwAPI representer for deletes.
This commit is contained in:
parent
2348b272e0
commit
fcf3128a56
2 changed files with 31 additions and 0 deletions
|
@ -96,6 +96,24 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_map(%Activity{data: %{"type" => "Delete", "published" => created_at, "object" => deleted_object }} = activity, %{user: user} = opts) do
|
||||||
|
created_at = created_at |> Utils.date_to_asctime
|
||||||
|
|
||||||
|
%{
|
||||||
|
"id" => activity.data["object"],
|
||||||
|
"user" => UserView.render("show.json", %{user: user, for: opts[:for]}),
|
||||||
|
"attentions" => [],
|
||||||
|
"statusnet_html" => "deleted notice {{tag",
|
||||||
|
"text" => "deleted notice {{tag" ,
|
||||||
|
"is_local" => activity.local,
|
||||||
|
"is_post_verb" => false,
|
||||||
|
"created_at" => created_at,
|
||||||
|
"in_reply_to_status_id" => nil,
|
||||||
|
"external_url" => activity.data["id"],
|
||||||
|
"activity_type" => "delete"
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def to_map(%Activity{data: %{"object" => %{"content" => content} = object}} = activity, %{user: user} = opts) do
|
def to_map(%Activity{data: %{"object" => %{"content" => content} = object}} = activity, %{user: user} = opts) do
|
||||||
created_at = object["published"] |> Utils.date_to_asctime
|
created_at = object["published"] |> Utils.date_to_asctime
|
||||||
like_count = object["like_count"] || 0
|
like_count = object["like_count"] || 0
|
||||||
|
|
|
@ -148,4 +148,17 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
|
||||||
assert map["is_post_verb"] == false
|
assert map["is_post_verb"] == false
|
||||||
assert map["activity_type"] == "undo"
|
assert map["activity_type"] == "undo"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "a delete activity" do
|
||||||
|
object = insert(:note)
|
||||||
|
user = User.get_by_ap_id(object.data["actor"])
|
||||||
|
|
||||||
|
{:ok, delete} = ActivityPub.delete(object)
|
||||||
|
|
||||||
|
map = ActivityRepresenter.to_map(delete, %{user: user})
|
||||||
|
|
||||||
|
assert map["is_post_verb"] == false
|
||||||
|
assert map["activity_type"] == "delete"
|
||||||
|
assert map["id"] == object.data["id"]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue