From a95d5da607f92faa1bc05f9d284086071a0a9d48 Mon Sep 17 00:00:00 2001 From: rinpatch Date: Thu, 17 Jan 2019 20:18:28 +0300 Subject: [PATCH] Don't show content if empty or zero width space --- lib/pleroma/web/metadata/opengraph.ex | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/pleroma/web/metadata/opengraph.ex b/lib/pleroma/web/metadata/opengraph.ex index 2f27a5300..cbd0b7d1b 100644 --- a/lib/pleroma/web/metadata/opengraph.ex +++ b/lib/pleroma/web/metadata/opengraph.ex @@ -10,8 +10,19 @@ defmodule Pleroma.Web.Metadata.Providers.OpenGraph do @behaviour Provider @impl Provider - def build_tags(%{activity: %{data: %{"object" => %{"id" => object_id}}} = activity, user: user}) do + def build_tags(%{ + activity: %{data: %{"object" => %{"id" => object_id}}} = activity, + user: user + }) do attachments = build_attachments(activity) + scrubbed_content = scrub_html_and_truncate(activity) + # Zero width space + content = + if scrubbed_content != "" and scrubbed_content != "\u200B" do + ": “" <> scrubbed_content <> "”" + else + "" + end # Most previews only show og:title which is inconvenient. Instagram # hacks this by putting the description in the title and making the @@ -23,13 +34,13 @@ defmodule Pleroma.Web.Metadata.Providers.OpenGraph do {:meta, [ property: "og:title", - content: "#{user.name}: " <> "“" <> scrub_html_and_truncate(activity) <> "”" + content: "#{user.name}" <> content ], []}, {:meta, [property: "og:url", content: object_id], []}, {:meta, [ property: "og:description", - content: "#{user_name_string(user)}: " <> "“" <> scrub_html_and_truncate(activity) <> "”" + content: "#{user_name_string(user)}" <> content ], []}, {:meta, [property: "og:type", content: "website"], []} ] ++