+
+ test "replaces keyword if string matches in history" do
+ clear_config([:mrf_keyword, :replace], [{"opensource", "free software"}])
+
+ message = %{
+ "type" => "Create",
+ "to" => ["https://www.w3.org/ns/activitystreams#Public"],
+ "object" => %{
+ "content" => "ZFS is opensource",
+ "summary" => "",
+ "formerRepresentations" => %{
+ "type" => "OrderedCollection",
+ "orderedItems" => [
+ %{"content" => "ZFS is opensource mew mew", "summary" => ""}
+ ]
+ }
+ }
+ }
+
+ {:ok,
+ %{
+ "object" => %{
+ "content" => "ZFS is free software",
+ "formerRepresentations" => %{
+ "orderedItems" => [%{"content" => "ZFS is free software mew mew"}]
+ }
+ }
+ }} = KeywordPolicy.filter(message)
+ end
+
+ test "replaces keyword in Updates" do
+ clear_config([:mrf_keyword, :replace], [{"opensource", "free software"}])
+
+ message = %{
+ "type" => "Update",
+ "to" => ["https://www.w3.org/ns/activitystreams#Public"],
+ "object" => %{
+ "content" => "ZFS is opensource",
+ "summary" => "",
+ "formerRepresentations" => %{
+ "type" => "OrderedCollection",
+ "orderedItems" => [
+ %{"content" => "ZFS is opensource mew mew", "summary" => ""}
+ ]
+ }
+ }
+ }
+
+ {:ok,
+ %{
+ "object" => %{
+ "content" => "ZFS is free software",
+ "formerRepresentations" => %{
+ "orderedItems" => [%{"content" => "ZFS is free software mew mew"}]
+ }
+ }
+ }} = KeywordPolicy.filter(message)
+ end