686f1c919fa847906f35fa2c447674d84d578eb6
[akkoma] / lib / pleroma / web / activity_pub / mrf / gab_rewrite_policy.ex
1 defmodule Pleroma.Web.ActivityPub.MRF.GABRewritePolicy do
2 @moduledoc "Adds stupid quotes to gab users"
3 @behaviour Pleroma.Web.ActivityPub.MRF
4 @domain "gab.com"
5 @appends [
6 "Sent from AOL Mobile Mail",
7 "John had surgery Friday and he's with the lord now.",
8 "Lovely pics as alway, Janice. I have terminal brain cancer.",
9 "DISCUSTING",
10 "I DID NOT POST THAT! SOMEONE HAS HACKED MY ACCOUNT",
11 "LOVE ETHYL",
12 "Just got back from the doctor. I have Ebola. See you at church on Sunday!",
13 "ADULT ONLY",
14 "Are you my grandson?",
15 "http://m.facebook.com",
16 "WISH GOD WOULD TAKE ME.",
17 "YOU SURE ARE A LONG BABY",
18 "REFURBISHD +OK?",
19 "THIS EMAIL IS INTENDED FOR THE RECIPIENT ONLY. PLEASE THINK ABOUT THE ENVIRONMENT BEFORE YOU PRINT THIS MESSAGE",
20 "AC/DC is my favourite band",
21 "BRAD'S WIFE!",
22 "Order corn!",
23 "Yim yum",
24 "My 49 year old son, Shane, died this morning.",
25 "I called Mr uber",
26 "Coconut oil.",
27 "price for apple sauce at walmart",
28 "no SWEARING on my timeline!"
29 ]
30
31 def add(%{"object" => %{"content" => content}} = object) do
32 put_in(object, ["object", "content"], content <> " " <> Enum.random(@appends))
33 end
34
35 @impl true
36 def filter(%{"type" => "Create", "actor" => actor} = object) do
37 actor_info = URI.parse(actor)
38 if String.contains?(actor_info.host, @domain) do
39 {:ok, add(object)}
40 else
41 {:ok, object}
42 end
43 end
44
45 def filter(object), do: {:ok, object}
46 end