Add actor to recipients
authorMaxim Filippov <colixer@gmail.com>
Fri, 18 Jan 2019 19:40:52 +0000 (22:40 +0300)
committerMaxim Filippov <colixer@gmail.com>
Fri, 18 Jan 2019 19:40:52 +0000 (22:40 +0300)
lib/pleroma/web/activity_pub/activity_pub.ex
test/web/mastodon_api/mastodon_api_controller_test.exs

index 5b87f746224c8d8d9683b54acf0643907f79894c..487d4c84a892fee848697c28bc5fc15b2b17dd26 100644 (file)
@@ -36,6 +36,14 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
     {recipients, to, cc}
   end
 
+  defp get_recipients(%{"type" => "Create"} = data) do
+    to = data["to"] || []
+    cc = data["cc"] || []
+    actor = data["actor"] || []
+    recipients = (to ++ cc ++ [actor]) |> Enum.uniq()
+    {recipients, to, cc}
+  end
+
   defp get_recipients(data) do
     to = data["to"] || []
     cc = data["cc"] || []
index fe8f845c7c0f6dde2a063cda4c76702d1bbd30aa..ce3aa5a026fd9041a65deaa813343c86eaa39c8e 100644 (file)
@@ -181,6 +181,16 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
     assert %{"visibility" => "direct"} = status
     assert status["url"] != direct.data["id"]
 
+    # User should be able to see his own direct message
+    res_conn =
+      build_conn()
+      |> assign(:user, user_one)
+      |> get("api/v1/timelines/direct")
+
+    [status] = json_response(res_conn, 200)
+
+    assert %{"visibility" => "direct"} = status
+
     # Both should be visible here
     res_conn =
       conn