Commit 7e9647b1 authored by lain's avatar lain
Browse files

Fix undo activity.

parent e343c0c9
......@@ -72,6 +72,26 @@ def to_map(%Activity{data: %{"type" => "Follow", "published" => created_at, "obj
}
end
# TODO:
# Make this more proper. Just a placeholder to not break the frontend.
def to_map(%Activity{data: %{"type" => "Undo", "published" => created_at, "object" => undid_activity }} = activity, %{user: user} = opts) do
created_at = created_at |> Utils.date_to_asctime
text = "#{user.nickname} undid the action at #{undid_activity}"
%{
"id" => activity.id,
"user" => UserView.render("show.json", %{user: user, for: opts[:for]}),
"attentions" => [],
"statusnet_html" => text,
"text" => text,
"is_local" => activity.local,
"is_post_verb" => false,
"created_at" => created_at,
"in_reply_to_status_id" => nil,
"external_url" => activity.data["id"]
}
end
def to_map(%Activity{data: %{"object" => %{"content" => content} = object}} = activity, %{user: user} = opts) do
created_at = object["published"] |> Utils.date_to_asctime
like_count = object["like_count"] || 0
......
......@@ -132,4 +132,15 @@ test "an activity" do
assert ActivityRepresenter.to_map(activity, %{user: user, for: follower, mentioned: [mentioned_user]}) == expected_status
end
test "an undo for a follow" do
follower = insert(:user)
followed = insert(:user)
{:ok, follow} = ActivityPub.follow(follower, followed)
{:ok, unfollow} = ActivityPub.unfollow(follower, followed)
map = ActivityRepresenter.to_map(unfollow, %{user: follower})
assert map["is_post_verb"] == false
end
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment