projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Changed references of "Pleroma" to "Akkoma" in email text
[akkoma]
/
lib
/
pleroma
/
web
/
activity_pub
/
mrf
/
no_empty_policy.ex
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 f4c5db05ca805386239fc121381340c23eb71411..19637a38d0f1a0e54aca234e15fc5b2c9b63a415 100644
(file)
--- a/
lib/pleroma/web/activity_pub/mrf/no_empty_policy.ex
+++ b/
lib/pleroma/web/activity_pub/mrf/no_empty_policy.ex
@@
-4,13
+4,14
@@
defmodule Pleroma.Web.ActivityPub.MRF.NoEmptyPolicy do
@moduledoc "Filter local activities which have no content"
defmodule Pleroma.Web.ActivityPub.MRF.NoEmptyPolicy do
@moduledoc "Filter local activities which have no content"
- @behaviour Pleroma.Web.ActivityPub.MRF
+ @behaviour Pleroma.Web.ActivityPub.MRF
.Policy
alias Pleroma.Web.Endpoint
@impl true
def filter(%{"actor" => actor} = object) do
with true <- is_local?(actor),
alias Pleroma.Web.Endpoint
@impl true
def filter(%{"actor" => actor} = object) do
with true <- is_local?(actor),
+ true <- is_eligible_type?(object),
true <- is_note?(object),
false <- has_attachment?(object),
true <- only_mentions?(object) do
true <- is_note?(object),
false <- has_attachment?(object),
true <- only_mentions?(object) do
@@
-32,7
+33,6
@@
defmodule Pleroma.Web.ActivityPub.MRF.NoEmptyPolicy do
end
defp has_attachment?(%{
end
defp has_attachment?(%{
- "type" => "Create",
"object" => %{"type" => "Note", "attachment" => attachments}
})
when length(attachments) > 0,
"object" => %{"type" => "Note", "attachment" => attachments}
})
when length(attachments) > 0,
@@
-40,7
+40,13
@@
defmodule Pleroma.Web.ActivityPub.MRF.NoEmptyPolicy do
defp has_attachment?(_), do: false
defp has_attachment?(_), do: false
- defp only_mentions?(%{"type" => "Create", "object" => %{"type" => "Note", "source" => source}}) do
+ defp only_mentions?(%{"object" => %{"type" => "Note", "source" => source}}) do
+ source =
+ case source do
+ %{"content" => text} -> text
+ _ -> source
+ end
+
non_mentions =
source |> String.split() |> Enum.filter(&(not String.starts_with?(&1, "@"))) |> length
non_mentions =
source |> String.split() |> Enum.filter(&(not String.starts_with?(&1, "@"))) |> length
@@
-53,9
+59,12
@@
defmodule Pleroma.Web.ActivityPub.MRF.NoEmptyPolicy do
defp only_mentions?(_), do: false
defp only_mentions?(_), do: false
- defp is_note?(%{"
type" => "Create", "
object" => %{"type" => "Note"}}), do: true
+ defp is_note?(%{"object" => %{"type" => "Note"}}), do: true
defp is_note?(_), do: false
defp is_note?(_), do: false
+ defp is_eligible_type?(%{"type" => type}) when type in ["Create", "Update"], do: true
+ defp is_eligible_type?(_), do: false
+
@impl true
def describe, do: {:ok, %{}}
end
@impl true
def describe, do: {:ok, %{}}
end