1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.Router do
6 use Pleroma.Web, :router
10 plug(Pleroma.Plugs.OAuthPlug)
14 plug(:accepts, ["json"])
16 plug(Pleroma.Plugs.OAuthPlug)
17 plug(Pleroma.Plugs.BasicAuthDecoderPlug)
18 plug(Pleroma.Plugs.UserFetcherPlug)
19 plug(Pleroma.Plugs.SessionAuthenticationPlug)
20 plug(Pleroma.Plugs.LegacyAuthenticationPlug)
21 plug(Pleroma.Plugs.AuthenticationPlug)
22 plug(Pleroma.Plugs.UserEnabledPlug)
23 plug(Pleroma.Plugs.SetUserSessionIdPlug)
24 plug(Pleroma.Plugs.EnsureUserKeyPlug)
27 pipeline :authenticated_api do
28 plug(:accepts, ["json"])
30 plug(Pleroma.Plugs.OAuthPlug)
31 plug(Pleroma.Plugs.BasicAuthDecoderPlug)
32 plug(Pleroma.Plugs.UserFetcherPlug)
33 plug(Pleroma.Plugs.SessionAuthenticationPlug)
34 plug(Pleroma.Plugs.LegacyAuthenticationPlug)
35 plug(Pleroma.Plugs.AuthenticationPlug)
36 plug(Pleroma.Plugs.UserEnabledPlug)
37 plug(Pleroma.Plugs.SetUserSessionIdPlug)
38 plug(Pleroma.Plugs.EnsureAuthenticatedPlug)
41 pipeline :admin_api do
42 plug(:accepts, ["json"])
44 plug(Pleroma.Plugs.OAuthPlug)
45 plug(Pleroma.Plugs.BasicAuthDecoderPlug)
46 plug(Pleroma.Plugs.UserFetcherPlug)
47 plug(Pleroma.Plugs.SessionAuthenticationPlug)
48 plug(Pleroma.Plugs.LegacyAuthenticationPlug)
49 plug(Pleroma.Plugs.AuthenticationPlug)
50 plug(Pleroma.Plugs.AdminSecretAuthenticationPlug)
51 plug(Pleroma.Plugs.UserEnabledPlug)
52 plug(Pleroma.Plugs.SetUserSessionIdPlug)
53 plug(Pleroma.Plugs.EnsureAuthenticatedPlug)
54 plug(Pleroma.Plugs.UserIsAdminPlug)
57 pipeline :mastodon_html do
58 plug(:accepts, ["html"])
60 plug(Pleroma.Plugs.OAuthPlug)
61 plug(Pleroma.Plugs.BasicAuthDecoderPlug)
62 plug(Pleroma.Plugs.UserFetcherPlug)
63 plug(Pleroma.Plugs.SessionAuthenticationPlug)
64 plug(Pleroma.Plugs.LegacyAuthenticationPlug)
65 plug(Pleroma.Plugs.AuthenticationPlug)
66 plug(Pleroma.Plugs.UserEnabledPlug)
67 plug(Pleroma.Plugs.SetUserSessionIdPlug)
68 plug(Pleroma.Plugs.EnsureUserKeyPlug)
71 pipeline :pleroma_html do
72 plug(:accepts, ["html"])
74 plug(Pleroma.Plugs.OAuthPlug)
75 plug(Pleroma.Plugs.BasicAuthDecoderPlug)
76 plug(Pleroma.Plugs.UserFetcherPlug)
77 plug(Pleroma.Plugs.SessionAuthenticationPlug)
78 plug(Pleroma.Plugs.AuthenticationPlug)
79 plug(Pleroma.Plugs.EnsureUserKeyPlug)
82 pipeline :oauth_read_or_unauthenticated do
83 plug(Pleroma.Plugs.OAuthScopesPlug, %{
85 fallback: :proceed_unauthenticated
89 pipeline :oauth_read do
90 plug(Pleroma.Plugs.OAuthScopesPlug, %{scopes: ["read"]})
93 pipeline :oauth_write do
94 plug(Pleroma.Plugs.OAuthScopesPlug, %{scopes: ["write"]})
97 pipeline :oauth_follow do
98 plug(Pleroma.Plugs.OAuthScopesPlug, %{scopes: ["follow"]})
101 pipeline :oauth_push do
102 plug(Pleroma.Plugs.OAuthScopesPlug, %{scopes: ["push"]})
105 pipeline :well_known do
106 plug(:accepts, ["json", "jrd+json", "xml", "xrd+xml"])
110 plug(:accepts, ["json", "xml"])
113 pipeline :pleroma_api do
114 plug(:accepts, ["html", "json"])
117 pipeline :mailbox_preview do
118 plug(:accepts, ["html"])
120 plug(:put_secure_browser_headers, %{
121 "content-security-policy" =>
122 "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline' 'unsafe-eval'"
126 scope "/api/pleroma", Pleroma.Web.TwitterAPI do
127 pipe_through(:pleroma_api)
129 get("/password_reset/:token", UtilController, :show_password_reset)
130 post("/password_reset", UtilController, :password_reset)
131 get("/emoji", UtilController, :emoji)
132 get("/captcha", UtilController, :captcha)
135 scope "/api/pleroma", Pleroma.Web do
136 pipe_through(:pleroma_api)
137 post("/uploader_callback/:upload_path", UploaderController, :callback)
140 scope "/api/pleroma/admin", Pleroma.Web.AdminAPI do
141 pipe_through([:admin_api, :oauth_write])
143 post("/user/follow", AdminAPIController, :user_follow)
144 post("/user/unfollow", AdminAPIController, :user_unfollow)
146 get("/users", AdminAPIController, :list_users)
147 get("/users/:nickname", AdminAPIController, :user_show)
149 delete("/user", AdminAPIController, :user_delete)
150 patch("/users/:nickname/toggle_activation", AdminAPIController, :user_toggle_activation)
151 post("/user", AdminAPIController, :user_create)
152 put("/users/tag", AdminAPIController, :tag_users)
153 delete("/users/tag", AdminAPIController, :untag_users)
155 get("/permission_group/:nickname", AdminAPIController, :right_get)
156 get("/permission_group/:nickname/:permission_group", AdminAPIController, :right_get)
157 post("/permission_group/:nickname/:permission_group", AdminAPIController, :right_add)
158 delete("/permission_group/:nickname/:permission_group", AdminAPIController, :right_delete)
160 put("/activation_status/:nickname", AdminAPIController, :set_activation_status)
162 post("/relay", AdminAPIController, :relay_follow)
163 delete("/relay", AdminAPIController, :relay_unfollow)
165 get("/invite_token", AdminAPIController, :get_invite_token)
166 post("/email_invite", AdminAPIController, :email_invite)
168 get("/password_reset", AdminAPIController, :get_password_reset)
171 scope "/", Pleroma.Web.TwitterAPI do
172 pipe_through(:pleroma_html)
174 post("/main/ostatus", UtilController, :remote_subscribe)
175 get("/ostatus_subscribe", UtilController, :remote_follow)
178 pipe_through(:oauth_follow)
179 post("/ostatus_subscribe", UtilController, :do_remote_follow)
183 scope "/api/pleroma", Pleroma.Web.TwitterAPI do
184 pipe_through(:authenticated_api)
187 pipe_through(:oauth_write)
189 post("/change_password", UtilController, :change_password)
190 post("/delete_account", UtilController, :delete_account)
194 pipe_through(:oauth_follow)
196 post("/blocks_import", UtilController, :blocks_import)
197 post("/follow_import", UtilController, :follow_import)
201 pipe_through(:oauth_read)
203 post("/notifications/read", UtilController, :notifications_read)
207 scope "/oauth", Pleroma.Web.OAuth do
210 get("/authorize", OAuthController, :authorize)
213 post("/authorize", OAuthController, :create_authorization)
214 post("/token", OAuthController, :token_exchange)
215 post("/revoke", OAuthController, :token_revoke)
218 scope "/api/v1", Pleroma.Web.MastodonAPI do
219 pipe_through(:authenticated_api)
222 pipe_through(:oauth_read)
224 get("/accounts/verify_credentials", MastodonAPIController, :verify_credentials)
226 get("/accounts/relationships", MastodonAPIController, :relationships)
227 get("/accounts/search", MastodonAPIController, :account_search)
229 get("/accounts/:id/lists", MastodonAPIController, :account_lists)
230 get("/accounts/:id/identity_proofs", MastodonAPIController, :empty_array)
232 get("/follow_requests", MastodonAPIController, :follow_requests)
233 get("/blocks", MastodonAPIController, :blocks)
234 get("/mutes", MastodonAPIController, :mutes)
236 get("/timelines/home", MastodonAPIController, :home_timeline)
237 get("/timelines/direct", MastodonAPIController, :dm_timeline)
239 get("/favourites", MastodonAPIController, :favourites)
240 get("/bookmarks", MastodonAPIController, :bookmarks)
242 post("/notifications/clear", MastodonAPIController, :clear_notifications)
243 post("/notifications/dismiss", MastodonAPIController, :dismiss_notification)
244 get("/notifications", MastodonAPIController, :notifications)
245 get("/notifications/:id", MastodonAPIController, :get_notification)
247 get("/scheduled_statuses", MastodonAPIController, :scheduled_statuses)
248 get("/scheduled_statuses/:id", MastodonAPIController, :show_scheduled_status)
250 get("/lists", MastodonAPIController, :get_lists)
251 get("/lists/:id", MastodonAPIController, :get_list)
252 get("/lists/:id/accounts", MastodonAPIController, :list_accounts)
254 get("/domain_blocks", MastodonAPIController, :domain_blocks)
256 get("/filters", MastodonAPIController, :get_filters)
258 get("/suggestions", MastodonAPIController, :suggestions)
260 get("/endorsements", MastodonAPIController, :empty_array)
262 get("/pleroma/flavour", MastodonAPIController, :get_flavour)
266 pipe_through(:oauth_write)
268 patch("/accounts/update_credentials", MastodonAPIController, :update_credentials)
270 post("/statuses", MastodonAPIController, :post_status)
271 delete("/statuses/:id", MastodonAPIController, :delete_status)
273 post("/statuses/:id/reblog", MastodonAPIController, :reblog_status)
274 post("/statuses/:id/unreblog", MastodonAPIController, :unreblog_status)
275 post("/statuses/:id/favourite", MastodonAPIController, :fav_status)
276 post("/statuses/:id/unfavourite", MastodonAPIController, :unfav_status)
277 post("/statuses/:id/pin", MastodonAPIController, :pin_status)
278 post("/statuses/:id/unpin", MastodonAPIController, :unpin_status)
279 post("/statuses/:id/bookmark", MastodonAPIController, :bookmark_status)
280 post("/statuses/:id/unbookmark", MastodonAPIController, :unbookmark_status)
281 post("/statuses/:id/mute", MastodonAPIController, :mute_conversation)
282 post("/statuses/:id/unmute", MastodonAPIController, :unmute_conversation)
284 put("/scheduled_statuses/:id", MastodonAPIController, :update_scheduled_status)
285 delete("/scheduled_statuses/:id", MastodonAPIController, :delete_scheduled_status)
287 post("/media", MastodonAPIController, :upload)
288 put("/media/:id", MastodonAPIController, :update_media)
290 delete("/lists/:id", MastodonAPIController, :delete_list)
291 post("/lists", MastodonAPIController, :create_list)
292 put("/lists/:id", MastodonAPIController, :rename_list)
294 post("/lists/:id/accounts", MastodonAPIController, :add_to_list)
295 delete("/lists/:id/accounts", MastodonAPIController, :remove_from_list)
297 post("/filters", MastodonAPIController, :create_filter)
298 get("/filters/:id", MastodonAPIController, :get_filter)
299 put("/filters/:id", MastodonAPIController, :update_filter)
300 delete("/filters/:id", MastodonAPIController, :delete_filter)
302 post("/pleroma/flavour/:flavour", MastodonAPIController, :set_flavour)
304 post("/reports", MastodonAPIController, :reports)
308 pipe_through(:oauth_follow)
310 post("/follows", MastodonAPIController, :follow)
311 post("/accounts/:id/follow", MastodonAPIController, :follow)
313 post("/accounts/:id/unfollow", MastodonAPIController, :unfollow)
314 post("/accounts/:id/block", MastodonAPIController, :block)
315 post("/accounts/:id/unblock", MastodonAPIController, :unblock)
316 post("/accounts/:id/mute", MastodonAPIController, :mute)
317 post("/accounts/:id/unmute", MastodonAPIController, :unmute)
319 post("/follow_requests/:id/authorize", MastodonAPIController, :authorize_follow_request)
320 post("/follow_requests/:id/reject", MastodonAPIController, :reject_follow_request)
322 post("/domain_blocks", MastodonAPIController, :block_domain)
323 delete("/domain_blocks", MastodonAPIController, :unblock_domain)
327 pipe_through(:oauth_push)
329 post("/push/subscription", SubscriptionController, :create)
330 get("/push/subscription", SubscriptionController, :get)
331 put("/push/subscription", SubscriptionController, :update)
332 delete("/push/subscription", SubscriptionController, :delete)
336 scope "/api/web", Pleroma.Web.MastodonAPI do
337 pipe_through([:authenticated_api, :oauth_write])
339 put("/settings", MastodonAPIController, :put_settings)
342 scope "/api/v1", Pleroma.Web.MastodonAPI do
345 get("/instance", MastodonAPIController, :masto_instance)
346 get("/instance/peers", MastodonAPIController, :peers)
347 post("/apps", MastodonAPIController, :create_app)
348 get("/apps/verify_credentials", MastodonAPIController, :verify_app_credentials)
349 get("/custom_emojis", MastodonAPIController, :custom_emojis)
351 get("/statuses/:id/card", MastodonAPIController, :status_card)
353 get("/statuses/:id/favourited_by", MastodonAPIController, :favourited_by)
354 get("/statuses/:id/reblogged_by", MastodonAPIController, :reblogged_by)
356 get("/trends", MastodonAPIController, :empty_array)
359 pipe_through(:oauth_read_or_unauthenticated)
361 get("/timelines/public", MastodonAPIController, :public_timeline)
362 get("/timelines/tag/:tag", MastodonAPIController, :hashtag_timeline)
363 get("/timelines/list/:list_id", MastodonAPIController, :list_timeline)
365 get("/statuses/:id", MastodonAPIController, :get_status)
366 get("/statuses/:id/context", MastodonAPIController, :get_context)
368 get("/accounts/:id/statuses", MastodonAPIController, :user_statuses)
369 get("/accounts/:id/followers", MastodonAPIController, :followers)
370 get("/accounts/:id/following", MastodonAPIController, :following)
371 get("/accounts/:id", MastodonAPIController, :user)
373 get("/search", MastodonAPIController, :search)
377 scope "/api/v2", Pleroma.Web.MastodonAPI do
378 pipe_through([:api, :oauth_read_or_unauthenticated])
379 get("/search", MastodonAPIController, :search2)
382 scope "/api", Pleroma.Web do
383 pipe_through(:config)
385 get("/help/test", TwitterAPI.UtilController, :help_test)
386 post("/help/test", TwitterAPI.UtilController, :help_test)
387 get("/statusnet/config", TwitterAPI.UtilController, :config)
388 get("/statusnet/version", TwitterAPI.UtilController, :version)
389 get("/pleroma/frontend_configurations", TwitterAPI.UtilController, :frontend_configurations)
392 scope "/api", Pleroma.Web do
395 post("/account/register", TwitterAPI.Controller, :register)
396 post("/account/password_reset", TwitterAPI.Controller, :password_reset)
398 post("/account/resend_confirmation_email", TwitterAPI.Controller, :resend_confirmation_email)
401 "/account/confirm_email/:user_id/:token",
402 TwitterAPI.Controller,
408 pipe_through(:oauth_read_or_unauthenticated)
410 get("/statuses/user_timeline", TwitterAPI.Controller, :user_timeline)
411 get("/qvitter/statuses/user_timeline", TwitterAPI.Controller, :user_timeline)
412 get("/users/show", TwitterAPI.Controller, :show_user)
414 get("/statuses/followers", TwitterAPI.Controller, :followers)
415 get("/statuses/friends", TwitterAPI.Controller, :friends)
416 get("/statuses/blocks", TwitterAPI.Controller, :blocks)
417 get("/statuses/show/:id", TwitterAPI.Controller, :fetch_status)
418 get("/statusnet/conversation/:id", TwitterAPI.Controller, :fetch_conversation)
420 get("/search", TwitterAPI.Controller, :search)
421 get("/statusnet/tags/timeline/:tag", TwitterAPI.Controller, :public_and_external_timeline)
425 scope "/api", Pleroma.Web do
426 pipe_through([:api, :oauth_read_or_unauthenticated])
428 get("/statuses/public_timeline", TwitterAPI.Controller, :public_timeline)
431 "/statuses/public_and_external_timeline",
432 TwitterAPI.Controller,
433 :public_and_external_timeline
436 get("/statuses/networkpublic_timeline", TwitterAPI.Controller, :public_and_external_timeline)
439 scope "/api", Pleroma.Web, as: :twitter_api_search do
440 pipe_through([:api, :oauth_read_or_unauthenticated])
441 get("/pleroma/search_user", TwitterAPI.Controller, :search_user)
444 scope "/api", Pleroma.Web, as: :authenticated_twitter_api do
445 pipe_through(:authenticated_api)
447 get("/oauth_tokens", TwitterAPI.Controller, :oauth_tokens)
448 delete("/oauth_tokens/:id", TwitterAPI.Controller, :revoke_token)
451 pipe_through(:oauth_read)
453 get("/account/verify_credentials", TwitterAPI.Controller, :verify_credentials)
454 post("/account/verify_credentials", TwitterAPI.Controller, :verify_credentials)
456 get("/statuses/home_timeline", TwitterAPI.Controller, :friends_timeline)
457 get("/statuses/friends_timeline", TwitterAPI.Controller, :friends_timeline)
458 get("/statuses/mentions", TwitterAPI.Controller, :mentions_timeline)
459 get("/statuses/mentions_timeline", TwitterAPI.Controller, :mentions_timeline)
460 get("/statuses/dm_timeline", TwitterAPI.Controller, :dm_timeline)
461 get("/qvitter/statuses/notifications", TwitterAPI.Controller, :notifications)
463 get("/pleroma/friend_requests", TwitterAPI.Controller, :friend_requests)
465 get("/friends/ids", TwitterAPI.Controller, :friends_ids)
466 get("/friendships/no_retweets/ids", TwitterAPI.Controller, :empty_array)
468 get("/mutes/users/ids", TwitterAPI.Controller, :empty_array)
469 get("/qvitter/mutes", TwitterAPI.Controller, :raw_empty_array)
471 get("/externalprofile/show", TwitterAPI.Controller, :external_profile)
473 post("/qvitter/statuses/notifications/read", TwitterAPI.Controller, :notifications_read)
477 pipe_through(:oauth_write)
479 post("/account/update_profile", TwitterAPI.Controller, :update_profile)
480 post("/account/update_profile_banner", TwitterAPI.Controller, :update_banner)
481 post("/qvitter/update_background_image", TwitterAPI.Controller, :update_background)
483 post("/statuses/update", TwitterAPI.Controller, :status_update)
484 post("/statuses/retweet/:id", TwitterAPI.Controller, :retweet)
485 post("/statuses/unretweet/:id", TwitterAPI.Controller, :unretweet)
486 post("/statuses/destroy/:id", TwitterAPI.Controller, :delete_post)
488 post("/statuses/pin/:id", TwitterAPI.Controller, :pin)
489 post("/statuses/unpin/:id", TwitterAPI.Controller, :unpin)
491 post("/statusnet/media/upload", TwitterAPI.Controller, :upload)
492 post("/media/upload", TwitterAPI.Controller, :upload_json)
493 post("/media/metadata/create", TwitterAPI.Controller, :update_media)
495 post("/favorites/create/:id", TwitterAPI.Controller, :favorite)
496 post("/favorites/create", TwitterAPI.Controller, :favorite)
497 post("/favorites/destroy/:id", TwitterAPI.Controller, :unfavorite)
499 post("/qvitter/update_avatar", TwitterAPI.Controller, :update_avatar)
503 pipe_through(:oauth_follow)
505 post("/pleroma/friendships/approve", TwitterAPI.Controller, :approve_friend_request)
506 post("/pleroma/friendships/deny", TwitterAPI.Controller, :deny_friend_request)
508 post("/friendships/create", TwitterAPI.Controller, :follow)
509 post("/friendships/destroy", TwitterAPI.Controller, :unfollow)
511 post("/blocks/create", TwitterAPI.Controller, :block)
512 post("/blocks/destroy", TwitterAPI.Controller, :unblock)
516 pipeline :ap_relay do
517 plug(:accepts, ["activity+json", "json"])
521 plug(:accepts, ["html", "xml", "atom", "activity+json", "json"])
525 plug(:accepts, ["json", "xml"])
528 scope "/", Pleroma.Web do
529 pipe_through(:ostatus)
531 get("/objects/:uuid", OStatus.OStatusController, :object)
532 get("/activities/:uuid", OStatus.OStatusController, :activity)
533 get("/notice/:id", OStatus.OStatusController, :notice)
534 get("/notice/:id/embed_player", OStatus.OStatusController, :notice_player)
535 get("/users/:nickname/feed", OStatus.OStatusController, :feed)
536 get("/users/:nickname", OStatus.OStatusController, :feed_redirect)
538 post("/users/:nickname/salmon", OStatus.OStatusController, :salmon_incoming)
539 post("/push/hub/:nickname", Websub.WebsubController, :websub_subscription_request)
540 get("/push/subscriptions/:id", Websub.WebsubController, :websub_subscription_confirmation)
541 post("/push/subscriptions/:id", Websub.WebsubController, :websub_incoming)
544 scope "/", Pleroma.Web do
545 pipe_through(:oembed)
547 get("/oembed", OEmbed.OEmbedController, :url)
550 pipeline :activitypub do
551 plug(:accepts, ["activity+json", "json"])
552 plug(Pleroma.Web.Plugs.HTTPSignaturePlug)
555 scope "/", Pleroma.Web.ActivityPub do
556 # XXX: not really ostatus
557 pipe_through(:ostatus)
559 get("/users/:nickname/followers", ActivityPubController, :followers)
560 get("/users/:nickname/following", ActivityPubController, :following)
561 get("/users/:nickname/outbox", ActivityPubController, :outbox)
562 get("/objects/:uuid/likes", ActivityPubController, :object_likes)
565 pipeline :activitypub_client do
566 plug(:accepts, ["activity+json", "json"])
568 plug(Pleroma.Plugs.OAuthPlug)
569 plug(Pleroma.Plugs.BasicAuthDecoderPlug)
570 plug(Pleroma.Plugs.UserFetcherPlug)
571 plug(Pleroma.Plugs.SessionAuthenticationPlug)
572 plug(Pleroma.Plugs.LegacyAuthenticationPlug)
573 plug(Pleroma.Plugs.AuthenticationPlug)
574 plug(Pleroma.Plugs.UserEnabledPlug)
575 plug(Pleroma.Plugs.SetUserSessionIdPlug)
576 plug(Pleroma.Plugs.EnsureUserKeyPlug)
579 scope "/", Pleroma.Web.ActivityPub do
580 pipe_through([:activitypub_client])
583 pipe_through(:oauth_read)
584 get("/api/ap/whoami", ActivityPubController, :whoami)
585 get("/users/:nickname/inbox", ActivityPubController, :read_inbox)
589 pipe_through(:oauth_write)
590 post("/users/:nickname/outbox", ActivityPubController, :update_outbox)
594 scope "/relay", Pleroma.Web.ActivityPub do
595 pipe_through(:ap_relay)
596 get("/", ActivityPubController, :relay)
599 scope "/", Pleroma.Web.ActivityPub do
600 pipe_through(:activitypub)
601 post("/inbox", ActivityPubController, :inbox)
602 post("/users/:nickname/inbox", ActivityPubController, :inbox)
605 scope "/.well-known", Pleroma.Web do
606 pipe_through(:well_known)
608 get("/host-meta", WebFinger.WebFingerController, :host_meta)
609 get("/webfinger", WebFinger.WebFingerController, :webfinger)
610 get("/nodeinfo", Nodeinfo.NodeinfoController, :schemas)
613 scope "/nodeinfo", Pleroma.Web do
614 get("/:version", Nodeinfo.NodeinfoController, :nodeinfo)
617 scope "/", Pleroma.Web.MastodonAPI do
618 pipe_through(:mastodon_html)
620 get("/web/login", MastodonAPIController, :login)
621 delete("/auth/sign_out", MastodonAPIController, :logout)
624 pipe_through(:oauth_read_or_unauthenticated)
625 get("/web/*path", MastodonAPIController, :index)
629 pipeline :remote_media do
632 scope "/proxy/", Pleroma.Web.MediaProxy do
633 pipe_through(:remote_media)
635 get("/:sig/:url", MediaProxyController, :remote)
636 get("/:sig/:url/:filename", MediaProxyController, :remote)
639 if Mix.env() == :dev do
641 pipe_through([:mailbox_preview])
643 forward("/mailbox", Plug.Swoosh.MailboxPreview, base_path: "/dev/mailbox")
647 scope "/", Fallback do
648 get("/registration/:token", RedirectController, :registration_page)
649 get("/:maybe_nickname_or_id", RedirectController, :redirector_with_meta)
650 get("/*path", RedirectController, :redirector)
652 options("/*path", RedirectController, :empty)
656 defmodule Fallback.RedirectController do
657 use Pleroma.Web, :controller
659 alias Pleroma.Web.Metadata
661 def redirector(conn, _params, code \\ 200) do
663 |> put_resp_content_type("text/html")
664 |> send_file(code, index_file_path())
667 def redirector_with_meta(conn, %{"maybe_nickname_or_id" => maybe_nickname_or_id} = params) do
668 with %User{} = user <- User.get_cached_by_nickname_or_id(maybe_nickname_or_id) do
669 redirector_with_meta(conn, %{user: user})
672 redirector(conn, params)
676 def redirector_with_meta(conn, params) do
677 {:ok, index_content} = File.read(index_file_path())
678 tags = Metadata.build_tags(params)
679 response = String.replace(index_content, "<!--server-generated-meta-->", tags)
682 |> put_resp_content_type("text/html")
683 |> send_resp(200, response)
686 def index_file_path do
687 Pleroma.Plugs.InstanceStatic.file_path("index.html")
690 def registration_page(conn, params) do
691 redirector(conn, params)
694 def empty(conn, _params) do