Commit a95d5da6 authored by rinpatch's avatar rinpatch
Browse files

Don't show content if empty or zero width space

parent 388ceb6a
......@@ -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 @@ def build_tags(%{activity: %{data: %{"object" => %{"id" => object_id}}} = activi
{: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"], []}
] ++
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment