UtilController: Return state of safe dm mentions.
authorlain <lain@soykaf.club>
Thu, 21 Mar 2019 15:16:26 +0000 (16:16 +0100)
committerlain <lain@soykaf.club>
Thu, 21 Mar 2019 15:20:58 +0000 (16:20 +0100)
lib/pleroma/web/twitter_api/controllers/util_controller.ex
test/web/twitter_api/util_controller_test.exs

index 320ec778c28526b88ba27dad9f9bf3b205724c03..faa733fec5741f9f873716c8ec52e92ea7db4089 100644 (file)
@@ -197,7 +197,9 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
           vapidPublicKey: vapid_public_key,
           accountActivationRequired:
             if(Keyword.get(instance, :account_activation_required, false), do: "1", else: "0"),
-          invitesEnabled: if(Keyword.get(instance, :invites_enabled, false), do: "1", else: "0")
+          invitesEnabled: if(Keyword.get(instance, :invites_enabled, false), do: "1", else: "0"),
+          safeDMMentionsEnabled:
+            if(Pleroma.Config.get([:instance, :safe_dm_mentions]), do: "1", else: "0")
         }
 
         pleroma_fe =
index 6e8a25056772cf7150af07c6a616ed3c860ae7b7..832fdc09692b118fe71a1e3d94a6e682ae254efb 100644 (file)
@@ -75,6 +75,29 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
   end
 
   describe "GET /api/statusnet/config.json" do
+    test "returns the state of safe_dm_mentions flag", %{conn: conn} do
+      option = Pleroma.Config.get([:instance, :safe_dm_mentions])
+      Pleroma.Config.put([:instance, :safe_dm_mentions], true)
+
+      response =
+        conn
+        |> get("/api/statusnet/config.json")
+        |> json_response(:ok)
+
+      assert response["site"]["safeDMMentionsEnabled"] == "1"
+
+      Pleroma.Config.put([:instance, :safe_dm_mentions], false)
+
+      response =
+        conn
+        |> get("/api/statusnet/config.json")
+        |> json_response(:ok)
+
+      assert response["site"]["safeDMMentionsEnabled"] == "0"
+
+      Pleroma.Config.put([:instance, :safe_dm_mentions], option)
+    end
+
     test "it returns the managed config", %{conn: conn} do
       Pleroma.Config.put([:instance, :managed_config], false)
       Pleroma.Config.put([:fe], theme: "rei-ayanami-towel")