Introduce optional unfurling of nsfw content
This commit is contained in:
parent
0256bd2f1d
commit
4d5f15cd42
4 changed files with 14 additions and 4 deletions
|
|
@ -3,6 +3,7 @@
|
|||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
defmodule Pleroma.Web.Metadata.Providers.OpenGraph do
|
||||
alias Pleroma.Web.Metadata.Providers.Provider
|
||||
alias Pleroma.Web.Metadata
|
||||
alias Pleroma.{HTML, Formatter, User}
|
||||
alias Pleroma.Web.MediaProxy
|
||||
|
||||
|
|
@ -32,7 +33,7 @@ defmodule Pleroma.Web.Metadata.Providers.OpenGraph do
|
|||
], []},
|
||||
{:meta, [property: "og:type", content: "website"], []}
|
||||
] ++
|
||||
if attachments == [] do
|
||||
if attachments == [] or Metadata.activity_nsfw?(activity) do
|
||||
[
|
||||
{:meta, [property: "og:image", content: attachment_url(User.avatar_url(user))], []},
|
||||
{:meta, [property: "og:image:width", content: 150], []},
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@
|
|||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
defmodule Pleroma.Web.Metadata.Providers.TwitterCard do
|
||||
alias Pleroma.Web.Metadata.Providers.Provider
|
||||
alias Pleroma.Web.Metadata
|
||||
|
||||
@behaviour Provider
|
||||
|
||||
@impl Provider
|
||||
def build_tags(%{activity: activity}) do
|
||||
if Enum.any?(activity.data["object"]["tag"], fn tag -> tag == "nsfw" end) or
|
||||
activity.data["object"]["attachment"] == [] do
|
||||
if Metadata.activity_nsfw?(activity) or activity.data["object"]["attachment"] == [] do
|
||||
build_tags(nil)
|
||||
else
|
||||
case find_first_acceptable_media_type(activity) do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue