add mrf
This commit is contained in:
parent
3c40b1a9ef
commit
a99ba09f1c
1 changed files with 50 additions and 0 deletions
50
pleroma/custom-modules/mrf_yeehaw_policy.ex
Normal file
50
pleroma/custom-modules/mrf_yeehaw_policy.ex
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
defmodule Pleroma.Web.ActivityPub.MRF.YeehawPolicy do
|
||||||
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||||
|
|
||||||
|
require Logger
|
||||||
|
|
||||||
|
@impl true
|
||||||
|
def filter(
|
||||||
|
%{
|
||||||
|
"type" => "Create",
|
||||||
|
"object" => %{"type" => "Note", "content" => _content} = object,
|
||||||
|
"actor" => actor
|
||||||
|
} = activity
|
||||||
|
) do
|
||||||
|
actor_info = URI.parse(actor)
|
||||||
|
local_instance = Pleroma.Config.get([Pleroma.Web.Endpoint, :url, :host])
|
||||||
|
try do
|
||||||
|
if actor_info.host == local_instance do
|
||||||
|
{:ok,
|
||||||
|
Map.put(
|
||||||
|
activity,
|
||||||
|
"object",
|
||||||
|
object |> update_in(["content"], fn x -> x <> "\n\n- Yeehaw" end)
|
||||||
|
)}
|
||||||
|
else
|
||||||
|
{:ok, activity}
|
||||||
|
end
|
||||||
|
rescue
|
||||||
|
err ->
|
||||||
|
Logger.warning(inspect(err))
|
||||||
|
{:ok, activity}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def filter(activity), do: {:ok, activity}
|
||||||
|
|
||||||
|
@impl true
|
||||||
|
def describe do
|
||||||
|
{:ok, %{}}
|
||||||
|
end
|
||||||
|
|
||||||
|
@impl true
|
||||||
|
def config_description do
|
||||||
|
%{
|
||||||
|
key: :mrf_yeehawpolicy,
|
||||||
|
related_policy: "Pleroma.Web.ActivityPub.MRF.YeeHawPolicy",
|
||||||
|
label: "YeeHaw at everyone",
|
||||||
|
description: "YeeHaw at everyone on the local instance"
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Add table
Add a link
Reference in a new issue