twitterapi: fix remaining test failures
authorWilliam Pitcock <nenolod@dereferenced.org>
Sun, 25 Nov 2018 21:16:44 +0000 (21:16 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Tue, 4 Dec 2018 04:52:09 +0000 (04:52 +0000)
lib/pleroma/web/twitter_api/representers/activity_representer.ex
test/web/twitter_api/representers/activity_representer_test.exs

index 436f9bf92b307d2db9e3f6637939b4083a4bed7e..8f91aeaf0bc3638ed03d036bdb951c9ec15530d9 100644 (file)
@@ -141,7 +141,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do
   end
 
   def to_map(
-        %Activity{data: %{"object" => %{"content" => content} = object}} = activity,
+        %Activity{data: %{"object" => object}} = activity,
         %{user: user} = opts
       ) do
     object = Object.normalize(object)
index 7cae4e4a141a18629eb4d085ec564588eb421575..314f2b51ff5b0780cb4265987f5d6c36026d7e81 100644 (file)
@@ -87,6 +87,26 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
 
     {:ok, convo_object} = Object.context_mapping("2hu") |> Repo.insert()
 
+    note_object = %{
+      "id" => "https://example.com/id/1",
+      "published" => date,
+      "type" => "Note",
+      "content" => content_html,
+      "summary" => "2hu",
+      "inReplyToStatusId" => 213_123,
+      "attachment" => [object.data],
+      "external_url" => "some url",
+      "like_count" => 5,
+      "announcement_count" => 3,
+      "context" => "2hu",
+      "tag" => ["content", "mentioning", "nsfw"],
+      "emoji" => %{
+        "2hu" => "corndog.png"
+      }
+    }
+
+    Object.create(note_object)
+
     to = [
       User.ap_followers(user),
       "https://www.w3.org/ns/activitystreams#Public",
@@ -100,24 +120,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
         "id" => "id",
         "to" => to,
         "actor" => User.ap_id(user),
-        "object" => %{
-          "published" => date,
-          "type" => "Note",
-          "content" => content_html,
-          "summary" => "2hu",
-          "inReplyToStatusId" => 213_123,
-          "attachment" => [
-            object
-          ],
-          "external_url" => "some url",
-          "like_count" => 5,
-          "announcement_count" => 3,
-          "context" => "2hu",
-          "tag" => ["content", "mentioning", "nsfw"],
-          "emoji" => %{
-            "2hu" => "corndog.png"
-          }
-        },
+        "object" => note_object["id"],
         "published" => date,
         "context" => "2hu"
       },
@@ -158,7 +161,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
       "tags" => ["nsfw", "content", "mentioning"],
       "activity_type" => "post",
       "possibly_sensitive" => true,
-      "uri" => activity.data["object"]["id"],
+      "uri" => note_object["id"],
       "visibility" => "direct",
       "summary" => "2hu"
     }