Objects who got updated would just pass the TagPolicy, undoing the moderation that was set in place for the Actor.
Now we check not only for Create activities, but also Update activities.
defp process_tag(
"mrf_tag:media-force-nsfw",
%{
defp process_tag(
"mrf_tag:media-force-nsfw",
%{
"object" => %{"attachment" => child_attachment}
} = message
)
"object" => %{"attachment" => child_attachment}
} = message
)
- when length(child_attachment) > 0 do
+ when length(child_attachment) > 0 and type in ["Create", "Update"] do
{:ok, Kernel.put_in(message, ["object", "sensitive"], true)}
end
defp process_tag(
"mrf_tag:media-strip",
%{
{:ok, Kernel.put_in(message, ["object", "sensitive"], true)}
end
defp process_tag(
"mrf_tag:media-strip",
%{
"object" => %{"attachment" => child_attachment} = object
} = message
)
"object" => %{"attachment" => child_attachment} = object
} = message
)
- when length(child_attachment) > 0 do
+ when length(child_attachment) > 0 and type in ["Create", "Update"] do
object = Map.delete(object, "attachment")
message = Map.put(message, "object", object)
object = Map.delete(object, "attachment")
message = Map.put(message, "object", object)
defp process_tag(
"mrf_tag:force-unlisted",
%{
defp process_tag(
"mrf_tag:force-unlisted",
%{
"to" => to,
"cc" => cc,
"actor" => actor,
"object" => object
} = message
"to" => to,
"cc" => cc,
"actor" => actor,
"object" => object
} = message
+ ) when type in ["Create", "Update"] do
user = User.get_cached_by_ap_id(actor)
if Enum.member?(to, Pleroma.Constants.as_public()) do
user = User.get_cached_by_ap_id(actor)
if Enum.member?(to, Pleroma.Constants.as_public()) do
defp process_tag(
"mrf_tag:sandbox",
%{
defp process_tag(
"mrf_tag:sandbox",
%{
"to" => to,
"cc" => cc,
"actor" => actor,
"object" => object
} = message
"to" => to,
"cc" => cc,
"actor" => actor,
"object" => object
} = message
+ ) when type in ["Create", "Update"] do
user = User.get_cached_by_ap_id(actor)
if Enum.member?(to, Pleroma.Constants.as_public()) or
user = User.get_cached_by_ap_id(actor)
if Enum.member?(to, Pleroma.Constants.as_public()) or
do: filter_message(target_actor, message)
@impl true
do: filter_message(target_actor, message)
@impl true
- def filter(%{"actor" => actor, "type" => "Create"} = message),
+ def filter(%{"actor" => actor, "type" => type} = message) when type in ["Create", "Update"],
do: filter_message(actor, message)
@impl true
do: filter_message(actor, message)
@impl true
+ edit_message = %{
+ "actor" => actor.ap_id,
+ "type" => "Update",
+ "object" => %{},
+ "to" => [@public, "f"],
+ "cc" => [@public, "d"]
+ }
+
+ edit_expect_message = %{
+ "actor" => actor.ap_id,
+ "type" => "Update",
+ "object" => %{"to" => ["f", actor.follower_address], "cc" => ["d"]},
+ "to" => ["f", actor.follower_address],
+ "cc" => ["d"]
+ }
+
assert TagPolicy.filter(message) == {:ok, except_message}
assert TagPolicy.filter(message) == {:ok, except_message}
+ assert TagPolicy.filter(edit_message) == {:ok, edit_expect_message}
+ edit_message = %{
+ "actor" => actor.ap_id,
+ "type" => "Update",
+ "object" => %{},
+ "to" => [@public, "f"],
+ "cc" => [actor.follower_address, "d"]
+ }
+
+ edit_expect_message = %{
+ "actor" => actor.ap_id,
+ "type" => "Update",
+ "object" => %{"to" => ["f", actor.follower_address], "cc" => ["d", @public]},
+ "to" => ["f", actor.follower_address],
+ "cc" => ["d", @public]
+ }
+
assert TagPolicy.filter(message) == {:ok, except_message}
assert TagPolicy.filter(message) == {:ok, except_message}
+ assert TagPolicy.filter(edit_message) == {:ok, edit_expect_message}
+ edit_message = %{
+ "actor" => actor.ap_id,
+ "type" => "Update",
+ "object" => %{"attachment" => ["file1"]}
+ }
+
+ edit_expect_message = %{
+ "actor" => actor.ap_id,
+ "type" => "Update",
+ "object" => %{}
+ }
+
assert TagPolicy.filter(message) == {:ok, except_message}
assert TagPolicy.filter(message) == {:ok, except_message}
+ assert TagPolicy.filter(edit_message) == {:ok, edit_expect_message}
"object" => %{"tag" => ["test"], "attachment" => ["file1"], "sensitive" => true}
}
"object" => %{"tag" => ["test"], "attachment" => ["file1"], "sensitive" => true}
}
+ edit_message = %{
+ "actor" => actor.ap_id,
+ "type" => "Update",
+ "object" => %{"tag" => ["test"], "attachment" => ["file1"]}
+ }
+
+ edit_expect_message = %{
+ "actor" => actor.ap_id,
+ "type" => "Update",
+ "object" => %{"tag" => ["test"], "attachment" => ["file1"], "sensitive" => true}
+ }
+
assert TagPolicy.filter(message) == {:ok, except_message}
assert TagPolicy.filter(message) == {:ok, except_message}
+ assert TagPolicy.filter(edit_message) == {:ok, edit_expect_message}