1 defmodule Pleroma.Web.Router do
2 use Pleroma.Web, :router
4 alias Pleroma.{Repo, User, Web.Router}
6 def user_fetcher(username) do
7 {:ok, Repo.get_by(User, %{nickname: username})}
11 plug :accepts, ["json"]
13 plug Pleroma.Plugs.AuthenticationPlug, %{fetcher: &Router.user_fetcher/1, optional: true}
16 pipeline :authenticated_api do
17 plug :accepts, ["json"]
19 plug Pleroma.Plugs.AuthenticationPlug, %{fetcher: &Router.user_fetcher/1}
22 pipeline :well_known do
23 plug :accepts, ["xml", "xrd+xml"]
27 plug :accepts, ["json", "xml"]
30 scope "/api", Pleroma.Web do
33 get "/help/test", TwitterAPI.UtilController, :help_test
34 post "/help/test", TwitterAPI.UtilController, :help_test
35 get "/statusnet/config", TwitterAPI.UtilController, :config
36 get "/statusnet/version", TwitterAPI.UtilController, :version
39 scope "/api", Pleroma.Web do
42 get "/statuses/public_timeline", TwitterAPI.Controller, :public_timeline
43 get "/statuses/public_and_external_timeline", TwitterAPI.Controller, :public_and_external_timeline
44 get "/statuses/networkpublic_timeline", TwitterAPI.Controller, :public_and_external_timeline
45 get "/statuses/user_timeline", TwitterAPI.Controller, :user_timeline
46 get "/qvitter/statuses/user_timeline", TwitterAPI.Controller, :user_timeline
48 get "/statuses/show/:id", TwitterAPI.Controller, :fetch_status
49 get "/statusnet/conversation/:id", TwitterAPI.Controller, :fetch_conversation
51 post "/account/register", TwitterAPI.Controller, :register
53 get "/externalprofile/show", TwitterAPI.Controller, :external_profile
56 scope "/api", Pleroma.Web do
57 pipe_through :authenticated_api
59 get "/account/verify_credentials", TwitterAPI.Controller, :verify_credentials
60 post "/account/verify_credentials", TwitterAPI.Controller, :verify_credentials
62 post "/account/most_recent_notification", TwitterAPI.Controller, :update_most_recent_notification
64 get "/statuses/home_timeline", TwitterAPI.Controller, :friends_timeline
65 get "/statuses/friends_timeline", TwitterAPI.Controller, :friends_timeline
66 get "/statuses/mentions", TwitterAPI.Controller, :mentions_timeline
67 get "/statuses/mentions_timeline", TwitterAPI.Controller, :mentions_timeline
69 post "/statuses/update", TwitterAPI.Controller, :status_update
70 post "/statuses/retweet/:id", TwitterAPI.Controller, :retweet
72 post "/friendships/create", TwitterAPI.Controller, :follow
73 post "/friendships/destroy", TwitterAPI.Controller, :unfollow
75 post "/statusnet/media/upload", TwitterAPI.Controller, :upload
76 post "/media/upload", TwitterAPI.Controller, :upload_json
78 post "/favorites/create/:id", TwitterAPI.Controller, :favorite
79 post "/favorites/create", TwitterAPI.Controller, :favorite
80 post "/favorites/destroy/:id", TwitterAPI.Controller, :unfavorite
82 post "/qvitter/update_avatar", TwitterAPI.Controller, :update_avatar
84 get "/statuses/followers", TwitterAPI.Controller, :followers
85 get "/statuses/friends", TwitterAPI.Controller, :friends
89 plug :accepts, ["xml", "atom", "html"]
92 scope "/", Pleroma.Web do
95 get "/objects/:uuid", OStatus.OStatusController, :object
96 get "/activities/:uuid", OStatus.OStatusController, :activity
98 get "/users/:nickname/feed", OStatus.OStatusController, :feed
99 get "/users/:nickname", OStatus.OStatusController, :feed_redirect
100 post "/users/:nickname/salmon", OStatus.OStatusController, :salmon_incoming
101 post "/push/hub/:nickname", Websub.WebsubController, :websub_subscription_request
102 get "/push/subscriptions/:id", Websub.WebsubController, :websub_subscription_confirmation
103 post "/push/subscriptions/:id", Websub.WebsubController, :websub_incoming
106 scope "/.well-known", Pleroma.Web do
107 pipe_through :well_known
109 get "/host-meta", WebFinger.WebFingerController, :host_meta
110 get "/webfinger", WebFinger.WebFingerController, :webfinger
113 scope "/", Fallback do
114 get "/*path", RedirectController, :redirector
118 defmodule Fallback.RedirectController do
119 use Pleroma.Web, :controller
120 def redirector(conn, _params) do
121 if Mix.env != :test do
123 |> put_resp_content_type("text/html")
124 |> send_file(200, "priv/static/index.html")