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.OAuthPlug
14 plug Pleroma.Plugs.AuthenticationPlug, %{fetcher: &Router.user_fetcher/1, optional: true}
17 pipeline :authenticated_api do
18 plug :accepts, ["json"]
20 plug Pleroma.Plugs.OAuthPlug
21 plug Pleroma.Plugs.AuthenticationPlug, %{fetcher: &Router.user_fetcher/1}
24 pipeline :well_known do
25 plug :accepts, ["xml", "xrd+xml"]
29 plug :accepts, ["json", "xml"]
33 plug :accepts, ["html", "json"]
36 scope "/oauth", Pleroma.Web.OAuth do
37 get "/authorize", OAuthController, :authorize
38 post "/authorize", OAuthController, :create_authorization
39 post "/token", OAuthController, :token_exchange
42 scope "/api/v1", Pleroma.Web.MastodonAPI do
44 get "/instance", MastodonAPIController, :masto_instance
45 post "/apps", MastodonAPIController, :create_app
47 get "/timelines/public", MastodonAPIController, :public_timeline
49 get "/statuses/:id", MastodonAPIController, :get_status
52 scope "/api/v1", Pleroma.Web.MastodonAPI do
53 pipe_through :authenticated_api
55 get "/accounts/verify_credentials", MastodonAPIController, :verify_credentials
56 get "/timelines/home", MastodonAPIController, :home_timeline
58 post "/statuses", MastodonAPIController, :post_status
61 scope "/api", Pleroma.Web do
64 get "/help/test", TwitterAPI.UtilController, :help_test
65 post "/help/test", TwitterAPI.UtilController, :help_test
66 get "/statusnet/config", TwitterAPI.UtilController, :config
67 get "/statusnet/version", TwitterAPI.UtilController, :version
70 scope "/api", Pleroma.Web do
73 get "/statuses/public_timeline", TwitterAPI.Controller, :public_timeline
74 get "/statuses/public_and_external_timeline", TwitterAPI.Controller, :public_and_external_timeline
75 get "/statuses/networkpublic_timeline", TwitterAPI.Controller, :public_and_external_timeline
76 get "/statuses/user_timeline", TwitterAPI.Controller, :user_timeline
77 get "/qvitter/statuses/user_timeline", TwitterAPI.Controller, :user_timeline
79 get "/statuses/show/:id", TwitterAPI.Controller, :fetch_status
80 get "/statusnet/conversation/:id", TwitterAPI.Controller, :fetch_conversation
82 post "/account/register", TwitterAPI.Controller, :register
84 get "/externalprofile/show", TwitterAPI.Controller, :external_profile
87 scope "/api", Pleroma.Web do
88 pipe_through :authenticated_api
90 get "/account/verify_credentials", TwitterAPI.Controller, :verify_credentials
91 post "/account/verify_credentials", TwitterAPI.Controller, :verify_credentials
93 post "/account/update_profile", TwitterAPI.Controller, :update_profile
94 post "/account/update_profile_banner", TwitterAPI.Controller, :update_banner
95 post "/qvitter/update_background_image", TwitterAPI.Controller, :update_background
97 post "/account/most_recent_notification", TwitterAPI.Controller, :update_most_recent_notification
99 get "/statuses/home_timeline", TwitterAPI.Controller, :friends_timeline
100 get "/statuses/friends_timeline", TwitterAPI.Controller, :friends_timeline
101 get "/statuses/mentions", TwitterAPI.Controller, :mentions_timeline
102 get "/statuses/mentions_timeline", TwitterAPI.Controller, :mentions_timeline
104 post "/statuses/update", TwitterAPI.Controller, :status_update
105 post "/statuses/retweet/:id", TwitterAPI.Controller, :retweet
106 post "/statuses/destroy/:id", TwitterAPI.Controller, :delete_post
108 post "/friendships/create", TwitterAPI.Controller, :follow
109 post "/friendships/destroy", TwitterAPI.Controller, :unfollow
111 post "/statusnet/media/upload", TwitterAPI.Controller, :upload
112 post "/media/upload", TwitterAPI.Controller, :upload_json
114 post "/favorites/create/:id", TwitterAPI.Controller, :favorite
115 post "/favorites/create", TwitterAPI.Controller, :favorite
116 post "/favorites/destroy/:id", TwitterAPI.Controller, :unfavorite
118 post "/qvitter/update_avatar", TwitterAPI.Controller, :update_avatar
120 get "/statuses/followers", TwitterAPI.Controller, :followers
121 get "/statuses/friends", TwitterAPI.Controller, :friends
125 plug :accepts, ["xml", "atom", "html"]
128 scope "/", Pleroma.Web do
129 pipe_through :ostatus
131 get "/objects/:uuid", OStatus.OStatusController, :object
132 get "/activities/:uuid", OStatus.OStatusController, :activity
134 get "/users/:nickname/feed", OStatus.OStatusController, :feed
135 get "/users/:nickname", OStatus.OStatusController, :feed_redirect
136 post "/users/:nickname/salmon", OStatus.OStatusController, :salmon_incoming
137 post "/push/hub/:nickname", Websub.WebsubController, :websub_subscription_request
138 get "/push/subscriptions/:id", Websub.WebsubController, :websub_subscription_confirmation
139 post "/push/subscriptions/:id", Websub.WebsubController, :websub_incoming
142 scope "/.well-known", Pleroma.Web do
143 pipe_through :well_known
145 get "/host-meta", WebFinger.WebFingerController, :host_meta
146 get "/webfinger", WebFinger.WebFingerController, :webfinger
149 scope "/", Fallback do
150 get "/*path", RedirectController, :redirector
154 defmodule Fallback.RedirectController do
155 use Pleroma.Web, :controller
156 def redirector(conn, _params) do
157 if Mix.env != :test do
159 |> put_resp_content_type("text/html")
160 |> send_file(200, "priv/static/index.html")