defp process_tag(
"mrf_tag:media-force-nsfw",
%{
- "type" => "Create",
+ "type" => type,
"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",
%{
- "type" => "Create",
+ "type" => type,
"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)
defp process_tag(
"mrf_tag:force-unlisted",
%{
- "type" => "Create",
+ "type" => type,
"to" => to,
"cc" => cc,
"actor" => actor,
"object" => object
} = message
- ) do
+ ) when type in ["Create", "Update"] do
user = User.get_cached_by_ap_id(actor)
if Enum.member?(to, Pleroma.Constants.as_public()) do
defp process_tag(
"mrf_tag:sandbox",
%{
- "type" => "Create",
+ "type" => type,
"to" => to,
"cc" => cc,
"actor" => actor,
"object" => object
} = message
- ) do
+ ) when type in ["Create", "Update"] do
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
- 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
"cc" => ["d"]
}
+ 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(edit_message) == {:ok, edit_expect_message}
end
end
"cc" => ["d", @public]
}
+ 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(edit_message) == {:ok, edit_expect_message}
end
end
"object" => %{}
}
+ 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(edit_message) == {:ok, edit_expect_message}
end
end
"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(edit_message) == {:ok, edit_expect_message}
end
end
end