Merge remote-tracking branch 'pleroma/develop' into cycles-router-api-routes
authorAlex Gleason <alex@alexgleason.me>
Fri, 28 May 2021 18:51:21 +0000 (13:51 -0500)
committerAlex Gleason <alex@alexgleason.me>
Fri, 28 May 2021 18:51:21 +0000 (13:51 -0500)
1  2 
lib/pleroma/web/router.ex

index 3550088bb34cde2db8f0dc364699e17eb5b91a8f,f5a582a7e4b89230403333a19783847fe5b40b23..95d56699ebdbc3af8f1f3fc832b665c49eb75175
@@@ -140,6 -140,10 +140,10 @@@ defmodule Pleroma.Web.Router d
      plug(Pleroma.Web.Plugs.MappedSignatureToIdentityPlug)
    end
  
+   pipeline :static_fe do
+     plug(Pleroma.Web.Plugs.StaticFEPlug)
+   end
    scope "/api/v1/pleroma", Pleroma.Web.TwitterAPI do
      pipe_through(:pleroma_api)
  
      get("/users/:nickname/credentials", AdminAPIController, :show_user_credentials)
      patch("/users/:nickname/credentials", AdminAPIController, :update_user_credentials)
  
-     get("/users", UserController, :list)
+     get("/users", UserController, :index)
      get("/users/:nickname", UserController, :show)
      get("/users/:nickname/statuses", AdminAPIController, :list_user_statuses)
      get("/users/:nickname/chats", AdminAPIController, :list_user_chats)
    scope "/", Pleroma.Web do
      # Note: html format is supported only if static FE is enabled
      # Note: http signature is only considered for json requests (no auth for non-json requests)
-     pipe_through([:accepts_html_json, :http_signature, Pleroma.Web.Plugs.StaticFEPlug])
+     pipe_through([:accepts_html_json, :http_signature, :static_fe])
  
      get("/objects/:uuid", OStatus.OStatusController, :object)
      get("/activities/:uuid", OStatus.OStatusController, :activity)
    scope "/", Pleroma.Web do
      # Note: html format is supported only if static FE is enabled
      # Note: http signature is only considered for json requests (no auth for non-json requests)
-     pipe_through([:accepts_html_xml_json, :http_signature, Pleroma.Web.Plugs.StaticFEPlug])
+     pipe_through([:accepts_html_xml_json, :http_signature, :static_fe])
  
      # Note: returns user _profile_ for json requests, redirects to user _feed_ for non-json ones
      get("/users/:nickname", Feed.UserController, :feed_redirect, as: :user_feed)
  
    scope "/", Pleroma.Web do
      # Note: html format is supported only if static FE is enabled
-     pipe_through([:accepts_html_xml, Pleroma.Web.Plugs.StaticFEPlug])
+     pipe_through([:accepts_html_xml, :static_fe])
  
      get("/users/:nickname/feed", Feed.UserController, :feed, as: :user_feed)
    end
      # The following two are S2S as well, see `ActivityPub.fetch_follow_information_for_user/1`:
      get("/users/:nickname/followers", ActivityPubController, :followers)
      get("/users/:nickname/following", ActivityPubController, :following)
+     get("/users/:nickname/collections/featured", ActivityPubController, :pinned)
    end
  
    scope "/", Pleroma.Web.ActivityPub do
      get("/embed/:id", EmbedController, :show)
    end
  
-   scope "/proxy/", Pleroma.Web.MediaProxy do
-     get("/preview/:sig/:url", MediaProxyController, :preview)
-     get("/preview/:sig/:url/:filename", MediaProxyController, :preview)
-     get("/:sig/:url", MediaProxyController, :remote)
-     get("/:sig/:url/:filename", MediaProxyController, :remote)
+   scope "/proxy/", Pleroma.Web do
+     get("/preview/:sig/:url", MediaProxy.MediaProxyController, :preview)
+     get("/preview/:sig/:url/:filename", MediaProxy.MediaProxyController, :preview)
+     get("/:sig/:url", MediaProxy.MediaProxyController, :remote)
+     get("/:sig/:url/:filename", MediaProxy.MediaProxyController, :remote)
    end
  
    if Pleroma.Config.get(:env) == :dev do
  
      options("/*path", RedirectController, :empty)
    end
 +
 +  # TODO: Change to Phoenix.Router.routes/1 for Phoenix 1.6.0+
 +  def get_api_routes do
 +    __MODULE__.__routes__()
 +    |> Enum.reject(fn r -> r.plug == Pleroma.Web.Fallback.RedirectController end)
 +    |> Enum.map(fn r ->
 +      r.path
 +      |> String.split("/", trim: true)
 +      |> List.first()
 +    end)
 +    |> Enum.uniq()
 +  end
  end