Transmogrifier.set_sensitive/1: Keep sensitive set to true
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Mon, 4 May 2020 21:32:53 +0000 (23:32 +0200)
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Mon, 4 May 2020 21:36:00 +0000 (23:36 +0200)
CHANGELOG.md
lib/pleroma/web/activity_pub/transmogrifier.ex
test/web/activity_pub/activity_pub_controller_test.exs

index 522285efe8e0b1f7d4e61264e17dab04b847258a..cdb8a208047529473aa6c36354426bae9cc1485f 100644 (file)
@@ -47,6 +47,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
 - Logger configuration through AdminFE
 - HTTP Basic Authentication permissions issue
 - ObjectAgePolicy didn't filter out old messages
+- Transmogrifier: Keep object sensitive settings for outgoing representation (AP C2S)
 
 ### Added
 - NodeInfo: ObjectAgePolicy settings to the `federation` list.
index 581e7040bfbbf3c2fd140e83283711e1010acb8f..3a4d364e79fcbb2e8e625cfec10a9ad44dc84951 100644 (file)
@@ -1195,6 +1195,10 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
     Map.put(object, "conversation", object["context"])
   end
 
+  def set_sensitive(%{"sensitive" => true} = object) do
+    object
+  end
+
   def set_sensitive(object) do
     tags = object["tag"] || []
     Map.put(object, "sensitive", "nsfw" in tags)
index a8f1f0e263e092d95aad2633386be3ba4039656c..5c8d20ac49750c502433ac2aac8db201b1845118 100644 (file)
@@ -820,21 +820,29 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
       activity: activity
     } do
       user = insert(:user)
+      conn = assign(conn, :user, user)
       object = Map.put(activity["object"], "sensitive", true)
       activity = Map.put(activity, "object", object)
 
-      result =
+      response =
         conn
-        |> assign(:user, user)
         |> put_req_header("content-type", "application/activity+json")
         |> post("/users/#{user.nickname}/outbox", activity)
         |> json_response(201)
 
-      assert Activity.get_by_ap_id(result["id"])
-      assert result["object"]
-      assert %Object{data: object} = Object.normalize(result["object"])
-      assert object["sensitive"] == activity["object"]["sensitive"]
-      assert object["content"] == activity["object"]["content"]
+      assert Activity.get_by_ap_id(response["id"])
+      assert response["object"]
+      assert %Object{data: response_object} = Object.normalize(response["object"])
+      assert response_object["sensitive"] == true
+      assert response_object["content"] == activity["object"]["content"]
+
+      representation =
+        conn
+        |> put_req_header("accept", "application/activity+json")
+        |> get(response["id"])
+        |> json_response(200)
+
+      assert representation["object"]["sensitive"] == true
     end
 
     test "it rejects an incoming activity with bogus type", %{conn: conn, activity: activity} do