mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-23 23:11:13 +00:00
Merge branch 'feature/rejectnonpublic' into 'develop'
Add MRF to drop all posts with "followers-only" or "direct" privacy settings See merge request pleroma/pleroma!202
This commit is contained in:
commit
bb639a362e
29
lib/pleroma/web/activity_pub/mrf/reject_non_public.ex
Normal file
29
lib/pleroma/web/activity_pub/mrf/reject_non_public.ex
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
defmodule Pleroma.Web.ActivityPub.MRF.RejectNonPublic do
|
||||||
|
alias Pleroma.User
|
||||||
|
@behaviour Pleroma.Web.ActivityPub.MRF
|
||||||
|
|
||||||
|
@impl true
|
||||||
|
def filter(object) do
|
||||||
|
if object["type"] == "Create" do
|
||||||
|
user = User.get_cached_by_ap_id(object["actor"])
|
||||||
|
public = "https://www.w3.org/ns/activitystreams#Public"
|
||||||
|
|
||||||
|
# Determine visibility
|
||||||
|
visibility =
|
||||||
|
cond do
|
||||||
|
public in object["to"] -> "public"
|
||||||
|
public in object["cc"] -> "unlisted"
|
||||||
|
user.follower_address in object["to"] -> "followers"
|
||||||
|
true -> "direct"
|
||||||
|
end
|
||||||
|
|
||||||
|
case visibility do
|
||||||
|
"public" -> {:ok, object}
|
||||||
|
"unlisted" -> {:ok, object}
|
||||||
|
_ -> {:reject, nil}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
{:ok, object}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue