ActivityPub MRF: fix nsfw tagging of objects with attachments by looking at the right...
authornenolod@dereferenced.org <William Pitcock>
Thu, 19 Apr 2018 12:29:35 +0000 (12:29 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Thu, 19 Apr 2018 12:45:09 +0000 (07:45 -0500)
lib/pleroma/web/activity_pub/mrf/simple_policy.ex

index 1322744f112fa712a67dd99ae1d881657abdbfec..cb8eaf1ec7a25d9c90529d5b96cf7fceec85735c 100644 (file)
@@ -23,10 +23,12 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicy do
 
   @media_nsfw Keyword.get(@mrf_policy, :media_nsfw)
   defp check_media_nsfw(actor_info, object) do
-    if actor_info.host in @media_nsfw and object["attachment"] != nil and length(object["attachment"]) > 0 do
-      tags = (object["tag"] || []) ++ ["nsfw"]
-      object = Map.put(object, "tags", tags)
-      object = Map.put(object, "sensitive", true)
+    child_object = object["object"]
+    if actor_info.host in @media_nsfw and child_object["attachment"] != nil and length(child_object["attachment"]) > 0 do
+      tags = (child_object["tag"] || []) ++ ["nsfw"]
+      child_object = Map.put(child_object, "tags", tags)
+      child_object = Map.put(child_object, "sensitive", true)
+      object = Map.put(object, "object", child_object)
     end
 
     {:ok, object}