relay: move to /relay endpoint from / due to webapp issues
authorWilliam Pitcock <nenolod@dereferenced.org>
Mon, 6 Aug 2018 08:13:05 +0000 (08:13 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Mon, 6 Aug 2018 08:22:16 +0000 (08:22 +0000)
lib/pleroma/user.ex
lib/pleroma/web/router.ex

index 327eb3ea31c8594961705f6da13e93966bdaafff..8d8c53dfc91463678816b674e08faf474cd9092c 100644 (file)
@@ -638,16 +638,18 @@ defmodule Pleroma.User do
   end
 
   def get_or_create_instance_user do
-    if user = get_by_ap_id(Pleroma.Web.Endpoint.url()) do
+    relay_uri = "#{Pleroma.Web.Endpoint.url()}/relay"
+
+    if user = get_by_ap_id(relay_uri) do
       user
     else
       changes =
         %User{}
         |> cast(%{}, [:ap_id, :nickname, :local])
-        |> put_change(:ap_id, Pleroma.Web.Endpoint.url())
+        |> put_change(:ap_id, relay_uri)
         |> put_change(:nickname, nil)
         |> put_change(:local, true)
-        |> put_change(:follower_address, Pleroma.Web.Endpoint.url() <> "/relay/followers")
+        |> put_change(:follower_address, relay_uri <> "/followers")
 
       {:ok, user} = Repo.insert(changes)
       user
index 3cb9962620967dec8f112839583ba3dc8ca88e53..48c3fb9a56af8e8a25fe7ab3f31865078a6e8651 100644 (file)
@@ -283,6 +283,10 @@ defmodule Pleroma.Web.Router do
     get("/externalprofile/show", TwitterAPI.Controller, :external_profile)
   end
 
+  pipeline :ap_relay do
+    plug(:accepts, ["activity+json"])
+  end
+
   pipeline :ostatus do
     plug(:accepts, ["xml", "atom", "html", "activity+json"])
   end
@@ -319,9 +323,8 @@ defmodule Pleroma.Web.Router do
   end
 
   if @federating do
-    scope "/", Pleroma.Web.ActivityPub do
-      # XXX: not really ostatus either
-      pipe_through(:ostatus)
+    scope "/relay", Pleroma.Web.ActivityPub do
+      pipe_through(:ap_relay)
       get("/", ActivityPubController, :relay)
     end