From e8570758f90f0ef040eab011d0584c59379ba743 Mon Sep 17 00:00:00 2001
From: William Pitcock <nenolod@dereferenced.org>
Date: Sun, 25 Nov 2018 21:16:44 +0000
Subject: [PATCH] twitterapi: fix remaining test failures

---
 .../representers/activity_representer.ex      |  2 +-
 .../activity_representer_test.exs             | 41 ++++++++++---------
 2 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/lib/pleroma/web/twitter_api/representers/activity_representer.ex b/lib/pleroma/web/twitter_api/representers/activity_representer.ex
index 436f9bf92..8f91aeaf0 100644
--- a/lib/pleroma/web/twitter_api/representers/activity_representer.ex
+++ b/lib/pleroma/web/twitter_api/representers/activity_representer.ex
@@ -141,7 +141,7 @@ def to_map(
   end
 
   def to_map(
-        %Activity{data: %{"object" => %{"content" => content} = object}} = activity,
+        %Activity{data: %{"object" => object}} = activity,
         %{user: user} = opts
       ) do
     object = Object.normalize(object)
diff --git a/test/web/twitter_api/representers/activity_representer_test.exs b/test/web/twitter_api/representers/activity_representer_test.exs
index 7cae4e4a1..314f2b51f 100644
--- a/test/web/twitter_api/representers/activity_representer_test.exs
+++ b/test/web/twitter_api/representers/activity_representer_test.exs
@@ -87,6 +87,26 @@ test "an activity" 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 @@ test "an activity" 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 @@ test "an activity" do
       "tags" => ["nsfw", "content", "mentioning"],
       "activity_type" => "post",
       "possibly_sensitive" => true,
-      "uri" => activity.data["object"]["id"],
+      "uri" => note_object["id"],
       "visibility" => "direct",
       "summary" => "2hu"
     }