Add delete to TwAPI representer correctly.
authorRoger Braun <roger@rogerbraun.net>
Mon, 4 Sep 2017 18:48:29 +0000 (20:48 +0200)
committerRoger Braun <roger@rogerbraun.net>
Mon, 4 Sep 2017 18:48:29 +0000 (20:48 +0200)
lib/pleroma/web/twitter_api/representers/activity_representer.ex
lib/pleroma/web/twitter_api/twitter_api.ex

index 321917e838990d1a064ab03853623e1b8171ea8f..b0769de8917b6823c35a6c6cdfe69e252f2392a4 100644 (file)
@@ -100,7 +100,8 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do
     created_at = created_at |> Utils.date_to_asctime
 
     %{
-      "id" => activity.data["object"],
+      "id" => activity.id,
+      "uri" => activity.data["object"],
       "user" => UserView.render("show.json", %{user: user, for: opts[:for]}),
       "attentions" => [],
       "statusnet_html" => "deleted notice {{tag",
@@ -135,6 +136,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do
 
     %{
       "id" => activity.id,
+      "uri" => activity.data["object"]["id"],
       "user" => UserView.render("show.json", %{user: user, for: opts[:for]}),
       "statusnet_html" => HtmlSanitizeEx.basic_html(content) |> Formatter.finmojifiy,
       "text" => HtmlSanitizeEx.strip_tags(content),
index de39834ca83b5abc796834a9dd9a443f70767695..1ae076e2430eb5628e08ee9aeb1a329291785cb9 100644 (file)
@@ -265,6 +265,12 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
     ActivityRepresenter.to_map(activity, Map.merge(opts, %{users: [user, announced_actor], announced_activity: announced_activity}))
   end
 
+  defp activity_to_status(%Activity{data: %{"type" => "Delete"}} = activity, opts) do
+    actor = get_in(activity.data, ["actor"])
+    user = User.get_cached_by_ap_id(actor)
+    ActivityRepresenter.to_map(activity, Map.merge(opts, %{user: user}))
+  end
+
   defp activity_to_status(activity, opts) do
     actor = get_in(activity.data, ["actor"])
     user = User.get_cached_by_ap_id(actor)