Fix undo activity.
[akkoma] / lib / pleroma / web / twitter_api / representers / activity_representer.ex
index a03b34ffb9a29b70c37f226cc59dd93908e44ee9..10aab919a74ef1beb91fbb1802ab4944f42b22e7 100644 (file)
@@ -72,6 +72,26 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do
     }
   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