TwitterAPI: Include favorited post in json
authoreal <eal@waifu.club>
Fri, 14 Dec 2018 06:24:18 +0000 (08:24 +0200)
committereal <eal@waifu.club>
Fri, 14 Dec 2018 06:24:18 +0000 (08:24 +0200)
lib/pleroma/web/twitter_api/views/activity_view.ex
test/web/twitter_api/views/activity_view_test.exs

index 83e8fb765b3d4a3cd1a735763b3cfd467258d372..e5caed28f5011162f20a96ee79d6c28bb69949c6 100644 (file)
@@ -190,6 +190,11 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do
 
     text = "#{user.nickname} favorited a status."
 
+    favorited_status =
+      if liked_activity,
+        do: render("activity.json", Map.merge(opts, %{activity: liked_activity})),
+        else: nil
+
     %{
       "id" => activity.id,
       "user" => UserView.render("show.json", %{user: user, for: opts[:for]}),
@@ -199,6 +204,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do
       "is_post_verb" => false,
       "uri" => "tag:#{activity.data["id"]}:objectType=Favourite",
       "created_at" => created_at,
+      "favorited_status" => favorited_status,
       "in_reply_to_status_id" => liked_activity_id,
       "external_url" => activity.data["id"],
       "activity_type" => "like"
index bc36b0e905b6dfdff22d48a04fa4630093b1c460..77b8d99e798d03e8d378b041a81dd25b6fcb77b5 100644 (file)
@@ -112,6 +112,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
     {:ok, like, _object} = CommonAPI.favorite(activity.id, other_user)
 
     result = ActivityView.render("activity.json", activity: like)
+    activity = Pleroma.Activity.get_by_ap_id(activity.data["id"])
 
     expected = %{
       "activity_type" => "like",
@@ -121,6 +122,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
       "in_reply_to_status_id" => activity.id,
       "is_local" => true,
       "is_post_verb" => false,
+      "favorited_status" => ActivityView.render("activity.json", activity: activity),
       "statusnet_html" => "shp favorited a status.",
       "text" => "shp favorited a status.",
       "uri" => "tag:#{like.data["id"]}:objectType=Favourite",
@@ -148,6 +150,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
       "in_reply_to_status_id" => nil,
       "is_local" => true,
       "is_post_verb" => false,
+      "favorited_status" => nil,
       "statusnet_html" => "shp favorited a status.",
       "text" => "shp favorited a status.",
       "uri" => "tag:#{like.data["id"]}:objectType=Favourite",