Remote Timeline: add Streaming support
[akkoma] / test / web / metadata / opengraph_test.exs
index 672942148756b1e5a31fff8565f365612e49a330..218540e6c36b9eb370a33486ccd3b44405c84b22 100644 (file)
@@ -1,11 +1,14 @@
 # Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
+
 defmodule Pleroma.Web.Metadata.Providers.OpenGraphTest do
   use Pleroma.DataCase
   import Pleroma.Factory
   alias Pleroma.Web.Metadata.Providers.OpenGraph
 
+  setup do: clear_config([Pleroma.Web.Metadata, :unfurl_nsfw])
+
   test "it renders all supported types of attachments and skips unknown types" do
     user = insert(:user)
 
@@ -14,6 +17,7 @@ defmodule Pleroma.Web.Metadata.Providers.OpenGraphTest do
         data: %{
           "actor" => user.ap_id,
           "tag" => [],
+          "id" => "https://pleroma.gov/objects/whatever",
           "content" => "pleroma in a nutshell",
           "attachment" => [
             %{
@@ -46,19 +50,7 @@ defmodule Pleroma.Web.Metadata.Providers.OpenGraphTest do
         }
       })
 
-    note_activity =
-      insert(:note_activity, %{
-        data: %{
-          "actor" => note.data["actor"],
-          "to" => note.data["to"],
-          "object" => note.data,
-          "context" => note.data["context"]
-        },
-        actor: note.data["actor"],
-        recipients: note.data["to"]
-      })
-
-    result = OpenGraph.build_tags(%{activity: note_activity, user: user})
+    result = OpenGraph.build_tags(%{object: note, url: note.data["id"], user: user})
 
     assert Enum.all?(
              [
@@ -81,8 +73,10 @@ defmodule Pleroma.Web.Metadata.Providers.OpenGraphTest do
       insert(:note, %{
         data: %{
           "actor" => user.ap_id,
+          "id" => "https://pleroma.gov/objects/whatever",
           "content" => "#cuteposting #nsfw #hambaga",
           "tag" => ["cuteposting", "nsfw", "hambaga"],
+          "sensitive" => true,
           "attachment" => [
             %{
               "url" => [
@@ -93,19 +87,7 @@ defmodule Pleroma.Web.Metadata.Providers.OpenGraphTest do
         }
       })
 
-    note_activity =
-      insert(:note_activity, %{
-        data: %{
-          "actor" => note.data["actor"],
-          "to" => note.data["to"],
-          "object" => note.data,
-          "context" => note.data["context"]
-        },
-        actor: note.data["actor"],
-        recipients: note.data["to"]
-      })
-
-    result = OpenGraph.build_tags(%{activity: note_activity, user: user})
+    result = OpenGraph.build_tags(%{object: note, url: note.data["id"], user: user})
 
     assert {:meta, [property: "og:image", content: "https://pleroma.gov/tenshi.png"], []} in result