From: William Pitcock Date: Sun, 23 Dec 2018 15:27:08 +0000 (+0000) Subject: activitypub: add is_private?/is_direct? helpers X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=ddae43eb43c5c63eeb0e93e60917b99b3ffb41d0;p=akkoma activitypub: add is_private?/is_direct? helpers --- diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 130c06028..1fedfa854 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -805,6 +805,14 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do "https://www.w3.org/ns/activitystreams#Public" in (data["to"] ++ (data["cc"] || [])) end + def is_private?(activity) do + !is_public?(activity) && Enum.any?(activity.data["to"], &String.contains?(&1, "/followers")) + end + + def is_direct?(activity) do + !is_public?(activity) && !is_private?(activity) + end + def visible_for_user?(activity, nil) do is_public?(activity) end