Disable previews for any activity, but create
authorrinpatch <rinpatch@sdf.org>
Wed, 16 Jan 2019 06:42:24 +0000 (09:42 +0300)
committerrinpatch <rinpatch@sdf.org>
Wed, 16 Jan 2019 06:42:24 +0000 (09:42 +0300)
lib/pleroma/web/metadata/opengraph.ex
lib/pleroma/web/ostatus/ostatus_controller.ex

index 33ff075c64bb4c7a1da955227bf1380faeb9c819..b158569748d5559da9833e10201d59728a35f63f 100644 (file)
@@ -71,7 +71,7 @@ defmodule Pleroma.Web.Metadata.Providers.OpenGraph do
     end)
   end
 
-  defp scrub_html_and_truncate(%{data: %{ "object" => %{ "content" => content}}} = activity) do
+  defp scrub_html_and_truncate(%{data: %{"object" => %{"content" => content}}} = activity) do
     content
     # html content comes from DB already encoded, decode first and scrub after
     |> HtmlEntities.decode()
@@ -80,7 +80,7 @@ defmodule Pleroma.Web.Metadata.Providers.OpenGraph do
     |> Formatter.truncate()
   end
 
-  defp scrub_html_and_truncate(content) do
+  defp scrub_html_and_truncate(content) when is_binary(content) do
     content
     # html content comes from DB already encoded, decode first and scrub after
     |> HtmlEntities.decode()
@@ -88,6 +88,7 @@ defmodule Pleroma.Web.Metadata.Providers.OpenGraph do
     |> HTML.strip_tags()
     |> Formatter.truncate()
   end
+
   defp attachment_url(url) do
     MediaProxy.url(url)
   end
index 2a47519d1b5407e192b896731434b59d11f0e458..f7ba5738937f4a32c9bbc8352262ba992472a2ab 100644 (file)
@@ -145,7 +145,15 @@ defmodule Pleroma.Web.OStatus.OStatusController do
          %User{} = user <- User.get_cached_by_ap_id(activity.data["actor"]) do
       case format = get_format(conn) do
         "html" ->
-          Fallback.RedirectController.redirector_with_meta(conn, %{activity: activity, user: user})
+          # Only Create actvities have a map at object
+          if is_map(activity.data["object"]) do
+            Fallback.RedirectController.redirector_with_meta(conn, %{
+              activity: activity,
+              user: user
+            })
+          else
+            Fallback.RedirectController.redirector(conn, nil)
+          end
 
         _ ->
           represent_activity(conn, format, activity, user)