X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Factivity_pub%2Fmrf%2Fno_empty_policy.ex;h=b2939a4d6db03e839b6c29a99243d0a939a74258;hb=07ea4d73e12c65cf3fd5c194a8eb1f27900ed17f;hp=80bef591e268f49168172bd46080aab83843235a;hpb=7f23dd6cc867e839ec721d34e3c114a68a5aed9e;p=akkoma diff --git a/lib/pleroma/web/activity_pub/mrf/no_empty_policy.ex b/lib/pleroma/web/activity_pub/mrf/no_empty_policy.ex index 80bef591e..b2939a4d6 100644 --- a/lib/pleroma/web/activity_pub/mrf/no_empty_policy.ex +++ b/lib/pleroma/web/activity_pub/mrf/no_empty_policy.ex @@ -40,7 +40,23 @@ defmodule Pleroma.Web.ActivityPub.MRF.NoEmptyPolicy do defp has_attachment?(_), do: false - defp only_mentions?(%{"type" => "Create", "object" => %{"type" => "Note", "source" => source}}) do + defp only_mentions?(%{"type" => "Create", "object" => %{"type" => "Note", "source" => source}}) + when is_binary(source) do + non_mentions = + source |> String.split() |> Enum.filter(&(not String.starts_with?(&1, "@"))) |> length + + if non_mentions > 0 do + false + else + true + end + end + + defp only_mentions?(%{ + "type" => "Create", + "object" => %{"type" => "Note", "source" => %{"content" => source}} + }) + when is_binary(source) do non_mentions = source |> String.split() |> Enum.filter(&(not String.starts_with?(&1, "@"))) |> length