* `max_retries`: The maximum number of times a federation job is retried
## Pleroma.Web.Metadata
-* `providers`: a list of metadata providers to enable. Providers avalible:
+* `providers`: a list of metadata providers to enable. Providers availible:
* Pleroma.Web.Metadata.Providers.OpenGraph
* Pleroma.Web.Metadata.Providers.TwitterCard
+* `unfurl_nsfw`: If set to `true` nsfw attachments will be shown in previews
raise ArgumentError, message: "make_tag invalid args"
end
end
+
+ def activity_nsfw?(%{data: %{"object" => %{"tag" => tags}}}) do
+ if(Pleroma.Config.get([__MODULE__, :unfurl_nsfw], false) == false) do
+ Enum.any?(tags, fn tag -> tag == "nsfw" end)
+ else
+ false
+ end
+ end
end
# 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
], []},
{: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], []},
# 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