only_safe query parameter for nsfw free timelines, option to default for unauthenticated users
saw this requested, figured to write it up at least partly
rewrite restrict_media in lib/pleroma/web/activity_pub/activity_pub.ex fetch_activities_query to a case statement and include only_safe via a similar query
defp restrict_media(query, %{} = opts) do
case opts do
%{only_media: true} ->
from(
[activity, object] in query,
where: fragment("(?)->>'type' = 'Create'", activity.data),
where: fragment("(?)->'attachment' <> '[]'", object.data)
)
%{only_safe: true} ->
from(
[activity, object] in query,
where: fragment("(?)->>'type' = 'Create'", activity.data),
where: fragment("(?)->'sensitive' <> 'true'", object.data),
where: fragment("(?)->'attachment' = '[]'", object.data)
)
_ ->
query
end
end
an option to force it for users not logged in was tacked on, but i'm not sure on the place to deal with that, adding a :media Config to restrict_unauthenticated
is clear, but not which code path it should apply to