Merge branch 'develop' of https://git.pleroma.social/pleroma/pleroma into develop
[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 "MILK TRUK JUST ARRIVE",
30 "Also my catheter bag is full.",
31 "Go finish your yoghurt",
32 "I am going to slap your mouth grandson."
33 ]
34
35 def add(%{"object" => %{"content" => content}} = object) do
36 put_in(object, ["object", "content"], content <> " " <> Enum.random(@appends))
37 end
38
39 @impl true
40 def describe, do: {:ok, %{}}
41
42 @impl true
43 def filter(%{"type" => "Create", "actor" => actor} = object) do
44 actor_info = URI.parse(actor)
45 if String.contains?(actor_info.host, @domain) do
46 {:ok, add(object)}
47 else
48 {:ok, object}
49 end
50 end
51
52 def filter(object), do: {:ok, object}
53 end