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
43 pipe_through :authenticated_api
45 get "/accounts/verify_credentials", MastodonAPIController, :verify_credentials
46 get "/accounts/relationships", MastodonAPIController, :relationships
48 get "/timelines/home", MastodonAPIController, :home_timeline
50 post "/statuses", MastodonAPIController, :post_status
51 delete "/statuses/:id", MastodonAPIController, :delete_status
53 post "/statuses/:id/reblog", MastodonAPIController, :reblog_status
54 post "/statuses/:id/favourite", MastodonAPIController, :fav_status
55 post "/statuses/:id/unfavourite", MastodonAPIController, :unfav_status
57 get "/notifications", MastodonAPIController, :notifications
59 post "/media", MastodonAPIController, :upload
62 scope "/api/v1", Pleroma.Web.MastodonAPI do
64 get "/instance", MastodonAPIController, :masto_instance
65 post "/apps", MastodonAPIController, :create_app
67 get "/timelines/public", MastodonAPIController, :public_timeline
69 get "/statuses/:id", MastodonAPIController, :get_status
70 get "/statuses/:id/context", MastodonAPIController, :get_context
72 get "/accounts/:id/statuses", MastodonAPIController, :user_statuses
73 get "/accounts/:id", MastodonAPIController, :user
76 scope "/api", Pleroma.Web do
79 get "/help/test", TwitterAPI.UtilController, :help_test
80 post "/help/test", TwitterAPI.UtilController, :help_test
81 get "/statusnet/config", TwitterAPI.UtilController, :config
82 get "/statusnet/version", TwitterAPI.UtilController, :version
85 scope "/api", Pleroma.Web do
88 get "/statuses/public_timeline", TwitterAPI.Controller, :public_timeline
89 get "/statuses/public_and_external_timeline", TwitterAPI.Controller, :public_and_external_timeline
90 get "/statuses/networkpublic_timeline", TwitterAPI.Controller, :public_and_external_timeline
91 get "/statuses/user_timeline", TwitterAPI.Controller, :user_timeline
92 get "/qvitter/statuses/user_timeline", TwitterAPI.Controller, :user_timeline
94 get "/statuses/show/:id", TwitterAPI.Controller, :fetch_status
95 get "/statusnet/conversation/:id", TwitterAPI.Controller, :fetch_conversation
97 post "/account/register", TwitterAPI.Controller, :register
99 get "/externalprofile/show", TwitterAPI.Controller, :external_profile
102 scope "/api", Pleroma.Web do
103 pipe_through :authenticated_api
105 get "/account/verify_credentials", TwitterAPI.Controller, :verify_credentials
106 post "/account/verify_credentials", TwitterAPI.Controller, :verify_credentials
108 post "/account/update_profile", TwitterAPI.Controller, :update_profile
109 post "/account/update_profile_banner", TwitterAPI.Controller, :update_banner
110 post "/qvitter/update_background_image", TwitterAPI.Controller, :update_background
112 post "/account/most_recent_notification", TwitterAPI.Controller, :update_most_recent_notification
114 get "/statuses/home_timeline", TwitterAPI.Controller, :friends_timeline
115 get "/statuses/friends_timeline", TwitterAPI.Controller, :friends_timeline
116 get "/statuses/mentions", TwitterAPI.Controller, :mentions_timeline
117 get "/statuses/mentions_timeline", TwitterAPI.Controller, :mentions_timeline
119 post "/statuses/update", TwitterAPI.Controller, :status_update
120 post "/statuses/retweet/:id", TwitterAPI.Controller, :retweet
121 post "/statuses/destroy/:id", TwitterAPI.Controller, :delete_post
123 post "/friendships/create", TwitterAPI.Controller, :follow
124 post "/friendships/destroy", TwitterAPI.Controller, :unfollow
126 post "/statusnet/media/upload", TwitterAPI.Controller, :upload
127 post "/media/upload", TwitterAPI.Controller, :upload_json
129 post "/favorites/create/:id", TwitterAPI.Controller, :favorite
130 post "/favorites/create", TwitterAPI.Controller, :favorite
131 post "/favorites/destroy/:id", TwitterAPI.Controller, :unfavorite
133 post "/qvitter/update_avatar", TwitterAPI.Controller, :update_avatar
135 get "/statuses/followers", TwitterAPI.Controller, :followers
136 get "/statuses/friends", TwitterAPI.Controller, :friends
140 plug :accepts, ["xml", "atom", "html"]
143 scope "/", Pleroma.Web do
144 pipe_through :ostatus
146 get "/objects/:uuid", OStatus.OStatusController, :object
147 get "/activities/:uuid", OStatus.OStatusController, :activity
149 get "/users/:nickname/feed", OStatus.OStatusController, :feed
150 get "/users/:nickname", OStatus.OStatusController, :feed_redirect
151 post "/users/:nickname/salmon", OStatus.OStatusController, :salmon_incoming
152 post "/push/hub/:nickname", Websub.WebsubController, :websub_subscription_request
153 get "/push/subscriptions/:id", Websub.WebsubController, :websub_subscription_confirmation
154 post "/push/subscriptions/:id", Websub.WebsubController, :websub_incoming
157 scope "/.well-known", Pleroma.Web do
158 pipe_through :well_known
160 get "/host-meta", WebFinger.WebFingerController, :host_meta
161 get "/webfinger", WebFinger.WebFingerController, :webfinger
164 scope "/", Fallback do
165 get "/*path", RedirectController, :redirector
169 defmodule Fallback.RedirectController do
170 use Pleroma.Web, :controller
171 def redirector(conn, _params) do
172 if Mix.env != :test do
174 |> put_resp_content_type("text/html")
175 |> send_file(200, "priv/static/index.html")