c1d25f48857536a7446ede9e7ba425963d76f812
[akkoma] / lib / pleroma / web / activity_pub / mrf / reject_non_public.ex
1 defmodule Pleroma.Web.ActivityPub.MRF.RejectNonPublic do
2 alias Pleroma.User
3 @behaviour Pleroma.Web.ActivityPub.MRF
4
5 def filter(object) do
6 if object["type"] == "Create" do
7 user = User.get_by_ap_id(object["actor"])
8 public = "https://www.w3.org/ns/activitystreams#Public"
9
10 #Determine visibility
11 visibility =
12 cond do
13 public in object["to"] -> "public"
14 public in object["cc"] -> "unlisted"
15 user.follower_address in object["to"] -> "followers"
16 true -> "direct"
17 end
18
19 {flag, object_out} =
20 case visibility do
21 "public" -> {:ok, object}
22 "unlisted" -> {:ok, object}
23 _ -> {:reject, nil}
24 end
25
26 {flag, object_out}
27 else
28 {:ok, object}
29 end
30 end
31 end