1 defmodule Pleroma.Web.Router do
2 use Pleroma.Web, :router
4 alias Pleroma.{Repo, User, Web.Router}
7 plug(:accepts, ["json"])
9 plug(Pleroma.Plugs.OAuthPlug)
10 plug(Pleroma.Plugs.BasicAuthDecoderPlug)
11 plug(Pleroma.Plugs.UserFetcherPlug)
12 plug(Pleroma.Plugs.SessionAuthenticationPlug)
13 plug(Pleroma.Plugs.LegacyAuthenticationPlug)
14 plug(Pleroma.Plugs.AuthenticationPlug)
15 plug(Pleroma.Plugs.UserEnabledPlug)
16 plug(Pleroma.Plugs.SetUserSessionIdPlug)
17 plug(Pleroma.Plugs.EnsureUserKeyPlug)
20 pipeline :authenticated_api do
21 plug(:accepts, ["json"])
23 plug(Pleroma.Plugs.OAuthPlug)
24 plug(Pleroma.Plugs.BasicAuthDecoderPlug)
25 plug(Pleroma.Plugs.UserFetcherPlug)
26 plug(Pleroma.Plugs.SessionAuthenticationPlug)
27 plug(Pleroma.Plugs.LegacyAuthenticationPlug)
28 plug(Pleroma.Plugs.AuthenticationPlug)
29 plug(Pleroma.Plugs.UserEnabledPlug)
30 plug(Pleroma.Plugs.SetUserSessionIdPlug)
31 plug(Pleroma.Plugs.EnsureAuthenticatedPlug)
34 pipeline :admin_api do
35 plug(:accepts, ["json"])
37 plug(Pleroma.Plugs.OAuthPlug)
38 plug(Pleroma.Plugs.BasicAuthDecoderPlug)
39 plug(Pleroma.Plugs.UserFetcherPlug)
40 plug(Pleroma.Plugs.SessionAuthenticationPlug)
41 plug(Pleroma.Plugs.LegacyAuthenticationPlug)
42 plug(Pleroma.Plugs.AuthenticationPlug)
43 plug(Pleroma.Plugs.UserEnabledPlug)
44 plug(Pleroma.Plugs.SetUserSessionIdPlug)
45 plug(Pleroma.Plugs.EnsureAuthenticatedPlug)
46 plug(Pleroma.Plugs.UserIsAdminPlug)
49 pipeline :mastodon_html do
50 plug(:accepts, ["html"])
52 plug(Pleroma.Plugs.OAuthPlug)
53 plug(Pleroma.Plugs.BasicAuthDecoderPlug)
54 plug(Pleroma.Plugs.UserFetcherPlug)
55 plug(Pleroma.Plugs.SessionAuthenticationPlug)
56 plug(Pleroma.Plugs.LegacyAuthenticationPlug)
57 plug(Pleroma.Plugs.AuthenticationPlug)
58 plug(Pleroma.Plugs.UserEnabledPlug)
59 plug(Pleroma.Plugs.SetUserSessionIdPlug)
60 plug(Pleroma.Plugs.EnsureUserKeyPlug)
63 pipeline :pleroma_html do
64 plug(:accepts, ["html"])
66 plug(Pleroma.Plugs.OAuthPlug)
67 plug(Pleroma.Plugs.BasicAuthDecoderPlug)
68 plug(Pleroma.Plugs.UserFetcherPlug)
69 plug(Pleroma.Plugs.SessionAuthenticationPlug)
70 plug(Pleroma.Plugs.AuthenticationPlug)
71 plug(Pleroma.Plugs.EnsureUserKeyPlug)
74 pipeline :well_known do
75 plug(:accepts, ["json", "jrd+json", "xml", "xrd+xml"])
79 plug(:accepts, ["json", "xml"])
83 plug(:accepts, ["html", "json"])
86 pipeline :pleroma_api do
87 plug(:accepts, ["html", "json"])
90 scope "/api/pleroma", Pleroma.Web.TwitterAPI do
91 pipe_through(:pleroma_api)
92 get("/password_reset/:token", UtilController, :show_password_reset)
93 post("/password_reset", UtilController, :password_reset)
94 get("/emoji", UtilController, :emoji)
97 scope "/api/pleroma/admin", Pleroma.Web.AdminAPI do
98 pipe_through(:admin_api)
99 delete("/user", AdminAPIController, :user_delete)
100 post("/user", AdminAPIController, :user_create)
102 get("/permission_group/:nickname", AdminAPIController, :right_get)
103 get("/permission_group/:nickname/:permission_group", AdminAPIController, :right_get)
104 post("/permission_group/:nickname/:permission_group", AdminAPIController, :right_add)
105 delete("/permission_group/:nickname/:permission_group", AdminAPIController, :right_delete)
107 post("/relay", AdminAPIController, :relay_follow)
108 delete("/relay", AdminAPIController, :relay_unfollow)
110 get("/invite_token", AdminAPIController, :get_invite_token)
111 get("/password_reset", AdminAPIController, :get_password_reset)
114 scope "/", Pleroma.Web.TwitterAPI do
115 pipe_through(:pleroma_html)
116 get("/ostatus_subscribe", UtilController, :remote_follow)
117 post("/ostatus_subscribe", UtilController, :do_remote_follow)
118 post("/main/ostatus", UtilController, :remote_subscribe)
121 scope "/api/pleroma", Pleroma.Web.TwitterAPI do
122 pipe_through(:authenticated_api)
123 post("/follow_import", UtilController, :follow_import)
124 post("/change_password", UtilController, :change_password)
125 post("/delete_account", UtilController, :delete_account)
128 scope "/oauth", Pleroma.Web.OAuth do
129 get("/authorize", OAuthController, :authorize)
130 post("/authorize", OAuthController, :create_authorization)
131 post("/token", OAuthController, :token_exchange)
132 post("/revoke", OAuthController, :token_revoke)
135 scope "/api/v1", Pleroma.Web.MastodonAPI do
136 pipe_through(:authenticated_api)
138 patch("/accounts/update_credentials", MastodonAPIController, :update_credentials)
139 get("/accounts/verify_credentials", MastodonAPIController, :verify_credentials)
140 get("/accounts/relationships", MastodonAPIController, :relationships)
141 get("/accounts/search", MastodonAPIController, :account_search)
142 post("/accounts/:id/follow", MastodonAPIController, :follow)
143 post("/accounts/:id/unfollow", MastodonAPIController, :unfollow)
144 post("/accounts/:id/block", MastodonAPIController, :block)
145 post("/accounts/:id/unblock", MastodonAPIController, :unblock)
146 post("/accounts/:id/mute", MastodonAPIController, :relationship_noop)
147 post("/accounts/:id/unmute", MastodonAPIController, :relationship_noop)
148 get("/accounts/:id/lists", MastodonAPIController, :account_lists)
150 get("/follow_requests", MastodonAPIController, :follow_requests)
151 post("/follow_requests/:id/authorize", MastodonAPIController, :authorize_follow_request)
152 post("/follow_requests/:id/reject", MastodonAPIController, :reject_follow_request)
154 post("/follows", MastodonAPIController, :follow)
156 get("/blocks", MastodonAPIController, :blocks)
158 get("/mutes", MastodonAPIController, :empty_array)
160 get("/timelines/home", MastodonAPIController, :home_timeline)
162 get("/timelines/direct", MastodonAPIController, :dm_timeline)
164 get("/favourites", MastodonAPIController, :favourites)
166 post("/statuses", MastodonAPIController, :post_status)
167 delete("/statuses/:id", MastodonAPIController, :delete_status)
169 post("/statuses/:id/reblog", MastodonAPIController, :reblog_status)
170 post("/statuses/:id/unreblog", MastodonAPIController, :unreblog_status)
171 post("/statuses/:id/favourite", MastodonAPIController, :fav_status)
172 post("/statuses/:id/unfavourite", MastodonAPIController, :unfav_status)
174 post("/notifications/clear", MastodonAPIController, :clear_notifications)
175 post("/notifications/dismiss", MastodonAPIController, :dismiss_notification)
176 get("/notifications", MastodonAPIController, :notifications)
177 get("/notifications/:id", MastodonAPIController, :get_notification)
179 post("/media", MastodonAPIController, :upload)
180 put("/media/:id", MastodonAPIController, :update_media)
182 get("/lists", MastodonAPIController, :get_lists)
183 get("/lists/:id", MastodonAPIController, :get_list)
184 delete("/lists/:id", MastodonAPIController, :delete_list)
185 post("/lists", MastodonAPIController, :create_list)
186 put("/lists/:id", MastodonAPIController, :rename_list)
187 get("/lists/:id/accounts", MastodonAPIController, :list_accounts)
188 post("/lists/:id/accounts", MastodonAPIController, :add_to_list)
189 delete("/lists/:id/accounts", MastodonAPIController, :remove_from_list)
191 get("/domain_blocks", MastodonAPIController, :domain_blocks)
192 post("/domain_blocks", MastodonAPIController, :block_domain)
193 delete("/domain_blocks", MastodonAPIController, :unblock_domain)
195 get("/filters", MastodonAPIController, :get_filters)
196 post("/filters", MastodonAPIController, :create_filter)
197 get("/filters/:id", MastodonAPIController, :get_filter)
198 put("/filters/:id", MastodonAPIController, :update_filter)
199 delete("/filters/:id", MastodonAPIController, :delete_filter)
201 get("/suggestions", MastodonAPIController, :suggestions)
203 get("/endorsements", MastodonAPIController, :empty_array)
206 scope "/api/web", Pleroma.Web.MastodonAPI do
207 pipe_through(:authenticated_api)
209 put("/settings", MastodonAPIController, :put_settings)
212 scope "/api/v1", Pleroma.Web.MastodonAPI do
214 get("/instance", MastodonAPIController, :masto_instance)
215 get("/instance/peers", MastodonAPIController, :peers)
216 post("/apps", MastodonAPIController, :create_app)
217 get("/custom_emojis", MastodonAPIController, :custom_emojis)
219 get("/timelines/public", MastodonAPIController, :public_timeline)
220 get("/timelines/tag/:tag", MastodonAPIController, :hashtag_timeline)
221 get("/timelines/list/:list_id", MastodonAPIController, :list_timeline)
223 get("/statuses/:id", MastodonAPIController, :get_status)
224 get("/statuses/:id/context", MastodonAPIController, :get_context)
225 get("/statuses/:id/card", MastodonAPIController, :empty_object)
226 get("/statuses/:id/favourited_by", MastodonAPIController, :favourited_by)
227 get("/statuses/:id/reblogged_by", MastodonAPIController, :reblogged_by)
229 get("/accounts/:id/statuses", MastodonAPIController, :user_statuses)
230 get("/accounts/:id/followers", MastodonAPIController, :followers)
231 get("/accounts/:id/following", MastodonAPIController, :following)
232 get("/accounts/:id", MastodonAPIController, :user)
234 get("/trends", MastodonAPIController, :empty_array)
236 get("/search", MastodonAPIController, :search)
239 scope "/api/v2", Pleroma.Web.MastodonAPI do
241 get("/search", MastodonAPIController, :search2)
244 scope "/api", Pleroma.Web do
245 pipe_through(:config)
247 get("/help/test", TwitterAPI.UtilController, :help_test)
248 post("/help/test", TwitterAPI.UtilController, :help_test)
249 get("/statusnet/config", TwitterAPI.UtilController, :config)
250 get("/statusnet/version", TwitterAPI.UtilController, :version)
253 scope "/api", Pleroma.Web do
256 get("/statuses/user_timeline", TwitterAPI.Controller, :user_timeline)
257 get("/qvitter/statuses/user_timeline", TwitterAPI.Controller, :user_timeline)
258 get("/users/show", TwitterAPI.Controller, :show_user)
260 get("/statuses/followers", TwitterAPI.Controller, :followers)
261 get("/statuses/friends", TwitterAPI.Controller, :friends)
262 get("/statuses/show/:id", TwitterAPI.Controller, :fetch_status)
263 get("/statusnet/conversation/:id", TwitterAPI.Controller, :fetch_conversation)
265 post("/account/register", TwitterAPI.Controller, :register)
267 get("/search", TwitterAPI.Controller, :search)
268 get("/statusnet/tags/timeline/:tag", TwitterAPI.Controller, :public_and_external_timeline)
271 scope "/api", Pleroma.Web do
274 get("/statuses/public_timeline", TwitterAPI.Controller, :public_timeline)
277 "/statuses/public_and_external_timeline",
278 TwitterAPI.Controller,
279 :public_and_external_timeline
282 get("/statuses/networkpublic_timeline", TwitterAPI.Controller, :public_and_external_timeline)
285 scope "/api", Pleroma.Web, as: :twitter_api_search do
287 get("/pleroma/search_user", TwitterAPI.Controller, :search_user)
290 scope "/api", Pleroma.Web, as: :authenticated_twitter_api do
291 pipe_through(:authenticated_api)
293 get("/account/verify_credentials", TwitterAPI.Controller, :verify_credentials)
294 post("/account/verify_credentials", TwitterAPI.Controller, :verify_credentials)
296 post("/account/update_profile", TwitterAPI.Controller, :update_profile)
297 post("/account/update_profile_banner", TwitterAPI.Controller, :update_banner)
298 post("/qvitter/update_background_image", TwitterAPI.Controller, :update_background)
301 "/account/most_recent_notification",
302 TwitterAPI.Controller,
303 :update_most_recent_notification
306 get("/statuses/home_timeline", TwitterAPI.Controller, :friends_timeline)
307 get("/statuses/friends_timeline", TwitterAPI.Controller, :friends_timeline)
308 get("/statuses/mentions", TwitterAPI.Controller, :mentions_timeline)
309 get("/statuses/mentions_timeline", TwitterAPI.Controller, :mentions_timeline)
310 get("/statuses/dm_timeline", TwitterAPI.Controller, :dm_timeline)
311 get("/qvitter/statuses/notifications", TwitterAPI.Controller, :notifications)
313 # XXX: this is really a pleroma API, but we want to keep the pleroma namespace clean
315 post("/qvitter/statuses/notifications/read", TwitterAPI.Controller, :notifications_read)
317 post("/statuses/update", TwitterAPI.Controller, :status_update)
318 post("/statuses/retweet/:id", TwitterAPI.Controller, :retweet)
319 post("/statuses/unretweet/:id", TwitterAPI.Controller, :unretweet)
320 post("/statuses/destroy/:id", TwitterAPI.Controller, :delete_post)
322 get("/pleroma/friend_requests", TwitterAPI.Controller, :friend_requests)
323 post("/pleroma/friendships/approve", TwitterAPI.Controller, :approve_friend_request)
324 post("/pleroma/friendships/deny", TwitterAPI.Controller, :deny_friend_request)
326 post("/friendships/create", TwitterAPI.Controller, :follow)
327 post("/friendships/destroy", TwitterAPI.Controller, :unfollow)
328 post("/blocks/create", TwitterAPI.Controller, :block)
329 post("/blocks/destroy", TwitterAPI.Controller, :unblock)
331 post("/statusnet/media/upload", TwitterAPI.Controller, :upload)
332 post("/media/upload", TwitterAPI.Controller, :upload_json)
334 post("/favorites/create/:id", TwitterAPI.Controller, :favorite)
335 post("/favorites/create", TwitterAPI.Controller, :favorite)
336 post("/favorites/destroy/:id", TwitterAPI.Controller, :unfavorite)
338 post("/qvitter/update_avatar", TwitterAPI.Controller, :update_avatar)
340 get("/friends/ids", TwitterAPI.Controller, :friends_ids)
341 get("/friendships/no_retweets/ids", TwitterAPI.Controller, :empty_array)
343 get("/mutes/users/ids", TwitterAPI.Controller, :empty_array)
344 get("/qvitter/mutes", TwitterAPI.Controller, :raw_empty_array)
346 get("/externalprofile/show", TwitterAPI.Controller, :external_profile)
349 pipeline :ap_relay do
350 plug(:accepts, ["activity+json"])
354 plug(:accepts, ["xml", "atom", "html", "activity+json"])
357 scope "/", Pleroma.Web do
358 pipe_through(:ostatus)
360 get("/objects/:uuid", OStatus.OStatusController, :object)
361 get("/activities/:uuid", OStatus.OStatusController, :activity)
362 get("/notice/:id", OStatus.OStatusController, :notice)
363 get("/users/:nickname/feed", OStatus.OStatusController, :feed)
364 get("/users/:nickname", OStatus.OStatusController, :feed_redirect)
366 post("/users/:nickname/salmon", OStatus.OStatusController, :salmon_incoming)
367 post("/push/hub/:nickname", Websub.WebsubController, :websub_subscription_request)
368 get("/push/subscriptions/:id", Websub.WebsubController, :websub_subscription_confirmation)
369 post("/push/subscriptions/:id", Websub.WebsubController, :websub_incoming)
372 pipeline :activitypub do
373 plug(:accepts, ["activity+json"])
374 plug(Pleroma.Web.Plugs.HTTPSignaturePlug)
377 scope "/", Pleroma.Web.ActivityPub do
378 # XXX: not really ostatus
379 pipe_through(:ostatus)
381 get("/users/:nickname/followers", ActivityPubController, :followers)
382 get("/users/:nickname/following", ActivityPubController, :following)
383 get("/users/:nickname/outbox", ActivityPubController, :outbox)
386 scope "/relay", Pleroma.Web.ActivityPub do
387 pipe_through(:ap_relay)
388 get("/", ActivityPubController, :relay)
391 scope "/", Pleroma.Web.ActivityPub do
392 pipe_through(:activitypub)
393 post("/users/:nickname/inbox", ActivityPubController, :inbox)
394 post("/inbox", ActivityPubController, :inbox)
397 scope "/.well-known", Pleroma.Web do
398 pipe_through(:well_known)
400 get("/host-meta", WebFinger.WebFingerController, :host_meta)
401 get("/webfinger", WebFinger.WebFingerController, :webfinger)
402 get("/nodeinfo", Nodeinfo.NodeinfoController, :schemas)
405 scope "/nodeinfo", Pleroma.Web do
406 get("/:version", Nodeinfo.NodeinfoController, :nodeinfo)
409 scope "/", Pleroma.Web.MastodonAPI do
410 pipe_through(:mastodon_html)
412 get("/web/login", MastodonAPIController, :login)
413 post("/web/login", MastodonAPIController, :login_post)
414 get("/web/*path", MastodonAPIController, :index)
415 delete("/auth/sign_out", MastodonAPIController, :logout)
418 pipeline :remote_media do
421 scope "/proxy/", Pleroma.Web.MediaProxy do
422 pipe_through(:remote_media)
423 get("/:sig/:url", MediaProxyController, :remote)
424 get("/:sig/:url/:filename", MediaProxyController, :remote)
427 scope "/", Fallback do
428 get("/registration/:token", RedirectController, :registration_page)
429 get("/*path", RedirectController, :redirector)
431 options("/*path", RedirectController, :empty)
435 defmodule Fallback.RedirectController do
436 use Pleroma.Web, :controller
438 def redirector(conn, _params) do
439 if Mix.env() != :test do
441 |> put_resp_content_type("text/html")
442 |> send_file(200, "priv/static/index.html")
446 def registration_page(conn, params) do
447 redirector(conn, params)
450 def empty(conn, _params) do