2019-01-13 23:31:57 -06:00
|
|
|
# Pleroma: A lightweight social networking server
|
2022-02-26 00:11:42 -06:00
|
|
|
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
2019-01-13 23:31:57 -06:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Pleroma.Web.ActivityPub.MRF.NoPlaceholderTextPolicy do
|
2019-05-05 21:28:04 -05:00
|
|
|
@moduledoc "Ensure no content placeholder is present (such as the dot from mastodon)"
|
2021-06-07 14:22:08 -05:00
|
|
|
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
2019-01-13 23:31:57 -06:00
|
|
|
|
2022-07-23 21:41:04 -05:00
|
|
|
@impl true
|
|
|
|
def history_awareness, do: :auto
|
|
|
|
|
2019-01-13 23:31:57 -06:00
|
|
|
@impl true
|
|
|
|
def filter(
|
|
|
|
%{
|
2022-07-23 21:41:04 -05:00
|
|
|
"type" => type,
|
2019-07-10 00:12:21 -05:00
|
|
|
"object" => %{"content" => content, "attachment" => _} = _child_object
|
2019-01-13 23:31:57 -06:00
|
|
|
} = object
|
|
|
|
)
|
2022-07-23 21:41:04 -05:00
|
|
|
when type in ["Create", "Update"] and content in [".", "<p>.</p>"] do
|
2019-07-10 00:12:21 -05:00
|
|
|
{:ok, put_in(object, ["object", "content"], "")}
|
2019-01-13 23:31:57 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
@impl true
|
|
|
|
def filter(object), do: {:ok, object}
|
2019-08-13 16:52:54 -05:00
|
|
|
|
|
|
|
@impl true
|
2019-08-13 17:36:24 -05:00
|
|
|
def describe, do: {:ok, %{}}
|
2019-01-13 23:31:57 -06:00
|
|
|
end
|