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.OAuthPlug
20 plug Pleroma.Plugs.AuthenticationPlug, %{fetcher: &Router.user_fetcher/1}
23 pipeline :well_known do
24 plug :accepts, ["xml", "xrd+xml"]
28 plug :accepts, ["json", "xml"]
32 plug :accepts, ["html", "json"]
35 scope "/oauth", Pleroma.Web.OAuth do
36 get "/authorize", OAuthController, :authorize
37 post "/authorize", OAuthController, :create_authorization
38 post "/token", OAuthController, :token_exchange
41 scope "/api/v1", Pleroma.Web.MastodonAPI do
43 get "/instance", MastodonAPO.Controller, :masto_instance
44 post "/apps", MastodonAPIController, :create_app
47 scope "/api/v1", Pleroma.Web.MastodonAPI do
48 pipe_through :authenticated_api
50 get "/accounts/verify_credentials", MastodonAPIController, :verify_credentials
53 scope "/api", Pleroma.Web do
56 get "/help/test", TwitterAPI.UtilController, :help_test
57 post "/help/test", TwitterAPI.UtilController, :help_test
58 get "/statusnet/config", TwitterAPI.UtilController, :config
59 get "/statusnet/version", TwitterAPI.UtilController, :version
62 scope "/api", Pleroma.Web do
65 get "/statuses/public_timeline", TwitterAPI.Controller, :public_timeline
66 get "/statuses/public_and_external_timeline", TwitterAPI.Controller, :public_and_external_timeline
67 get "/statuses/networkpublic_timeline", TwitterAPI.Controller, :public_and_external_timeline
68 get "/statuses/user_timeline", TwitterAPI.Controller, :user_timeline
69 get "/qvitter/statuses/user_timeline", TwitterAPI.Controller, :user_timeline
71 get "/statuses/show/:id", TwitterAPI.Controller, :fetch_status
72 get "/statusnet/conversation/:id", TwitterAPI.Controller, :fetch_conversation
74 post "/account/register", TwitterAPI.Controller, :register
76 get "/externalprofile/show", TwitterAPI.Controller, :external_profile
79 scope "/api", Pleroma.Web do
80 pipe_through :authenticated_api
82 get "/account/verify_credentials", TwitterAPI.Controller, :verify_credentials
83 post "/account/verify_credentials", TwitterAPI.Controller, :verify_credentials
85 post "/account/update_profile", TwitterAPI.Controller, :update_profile
86 post "/account/update_profile_banner", TwitterAPI.Controller, :update_banner
87 post "/qvitter/update_background_image", TwitterAPI.Controller, :update_background
89 post "/account/most_recent_notification", TwitterAPI.Controller, :update_most_recent_notification
91 get "/statuses/home_timeline", TwitterAPI.Controller, :friends_timeline
92 get "/statuses/friends_timeline", TwitterAPI.Controller, :friends_timeline
93 get "/statuses/mentions", TwitterAPI.Controller, :mentions_timeline
94 get "/statuses/mentions_timeline", TwitterAPI.Controller, :mentions_timeline
96 post "/statuses/update", TwitterAPI.Controller, :status_update
97 post "/statuses/retweet/:id", TwitterAPI.Controller, :retweet
98 post "/statuses/destroy/:id", TwitterAPI.Controller, :delete_post
100 post "/friendships/create", TwitterAPI.Controller, :follow
101 post "/friendships/destroy", TwitterAPI.Controller, :unfollow
103 post "/statusnet/media/upload", TwitterAPI.Controller, :upload
104 post "/media/upload", TwitterAPI.Controller, :upload_json
106 post "/favorites/create/:id", TwitterAPI.Controller, :favorite
107 post "/favorites/create", TwitterAPI.Controller, :favorite
108 post "/favorites/destroy/:id", TwitterAPI.Controller, :unfavorite
110 post "/qvitter/update_avatar", TwitterAPI.Controller, :update_avatar
112 get "/statuses/followers", TwitterAPI.Controller, :followers
113 get "/statuses/friends", TwitterAPI.Controller, :friends
117 plug :accepts, ["xml", "atom", "html"]
120 scope "/", Pleroma.Web do
121 pipe_through :ostatus
123 get "/objects/:uuid", OStatus.OStatusController, :object
124 get "/activities/:uuid", OStatus.OStatusController, :activity
126 get "/users/:nickname/feed", OStatus.OStatusController, :feed
127 get "/users/:nickname", OStatus.OStatusController, :feed_redirect
128 post "/users/:nickname/salmon", OStatus.OStatusController, :salmon_incoming
129 post "/push/hub/:nickname", Websub.WebsubController, :websub_subscription_request
130 get "/push/subscriptions/:id", Websub.WebsubController, :websub_subscription_confirmation
131 post "/push/subscriptions/:id", Websub.WebsubController, :websub_incoming
134 scope "/.well-known", Pleroma.Web do
135 pipe_through :well_known
137 get "/host-meta", WebFinger.WebFingerController, :host_meta
138 get "/webfinger", WebFinger.WebFingerController, :webfinger
141 scope "/", Fallback do
142 get "/*path", RedirectController, :redirector
146 defmodule Fallback.RedirectController do
147 use Pleroma.Web, :controller
148 def redirector(conn, _params) do
149 if Mix.env != :test do
151 |> put_resp_content_type("text/html")
152 |> send_file(200, "priv/static/index.html")