Add a react to like MRF
Signed-off-by: Sam Therapy <sam@samtherapy.net>
This commit is contained in:
parent
46da3d8168
commit
5e7e56e305
1 changed files with 36 additions and 0 deletions
36
lib/pleroma/web/activity_pub/mrf/change_react_to_like.ex
Normal file
36
lib/pleroma/web/activity_pub/mrf/change_react_to_like.ex
Normal file
|
@ -0,0 +1,36 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.ActivityPub.MRF.ChangeReactstoLikes do
|
||||
require Logger
|
||||
|
||||
@moduledoc "Changes specified EmojiReacts into a Like"
|
||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||
|
||||
@impl true
|
||||
@spec filter(any) :: {:ok, any}
|
||||
def filter(%{"type" => "EmojiReact"} = object) do
|
||||
Logger.warn("#{inspect(object)}")
|
||||
test = object["content"]
|
||||
|
||||
# TODO: make this pull from config
|
||||
if test in ["👍", "❤️", "😆", "😮", "😢", "😩", "😭", "⭐"] do
|
||||
Logger.warn("MRF.ChangeReactstoLikes: Changing #{inspect(test)} to a Favourite")
|
||||
|
||||
object =
|
||||
object
|
||||
|> Map.put("type", "Like")
|
||||
|
||||
{:ok, object}
|
||||
else
|
||||
{:ok, object}
|
||||
end
|
||||
end
|
||||
|
||||
@impl true
|
||||
def filter(object), do: {:ok, object}
|
||||
|
||||
@impl true
|
||||
def describe, do: {:ok, %{}}
|
||||
end
|
Loading…
Reference in a new issue