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
9 plug(:accepts, ["html"])
15 plug(Pleroma.Plugs.OAuthPlug)
19 plug(:accepts, ["json"])
21 plug(Pleroma.Plugs.OAuthPlug)
22 plug(Pleroma.Plugs.BasicAuthDecoderPlug)
23 plug(Pleroma.Plugs.UserFetcherPlug)
24 plug(Pleroma.Plugs.SessionAuthenticationPlug)
25 plug(Pleroma.Plugs.LegacyAuthenticationPlug)
26 plug(Pleroma.Plugs.AuthenticationPlug)
27 plug(Pleroma.Plugs.UserEnabledPlug)
28 plug(Pleroma.Plugs.SetUserSessionIdPlug)
29 plug(Pleroma.Plugs.EnsureUserKeyPlug)
32 pipeline :authenticated_api do
33 plug(:accepts, ["json"])
35 plug(Pleroma.Plugs.OAuthPlug)
36 plug(Pleroma.Plugs.BasicAuthDecoderPlug)
37 plug(Pleroma.Plugs.UserFetcherPlug)
38 plug(Pleroma.Plugs.SessionAuthenticationPlug)
39 plug(Pleroma.Plugs.LegacyAuthenticationPlug)
40 plug(Pleroma.Plugs.AuthenticationPlug)
41 plug(Pleroma.Plugs.UserEnabledPlug)
42 plug(Pleroma.Plugs.SetUserSessionIdPlug)
43 plug(Pleroma.Plugs.EnsureAuthenticatedPlug)
46 pipeline :admin_api do
47 plug(:accepts, ["json"])
49 plug(Pleroma.Plugs.OAuthPlug)
50 plug(Pleroma.Plugs.BasicAuthDecoderPlug)
51 plug(Pleroma.Plugs.UserFetcherPlug)
52 plug(Pleroma.Plugs.SessionAuthenticationPlug)
53 plug(Pleroma.Plugs.LegacyAuthenticationPlug)
54 plug(Pleroma.Plugs.AuthenticationPlug)
55 plug(Pleroma.Plugs.AdminSecretAuthenticationPlug)
56 plug(Pleroma.Plugs.UserEnabledPlug)
57 plug(Pleroma.Plugs.SetUserSessionIdPlug)
58 plug(Pleroma.Plugs.EnsureAuthenticatedPlug)
59 plug(Pleroma.Plugs.UserIsAdminPlug)
62 pipeline :mastodon_html do
63 plug(:accepts, ["html"])
65 plug(Pleroma.Plugs.OAuthPlug)
66 plug(Pleroma.Plugs.BasicAuthDecoderPlug)
67 plug(Pleroma.Plugs.UserFetcherPlug)
68 plug(Pleroma.Plugs.SessionAuthenticationPlug)
69 plug(Pleroma.Plugs.LegacyAuthenticationPlug)
70 plug(Pleroma.Plugs.AuthenticationPlug)
71 plug(Pleroma.Plugs.UserEnabledPlug)
72 plug(Pleroma.Plugs.SetUserSessionIdPlug)
73 plug(Pleroma.Plugs.EnsureUserKeyPlug)
76 pipeline :pleroma_html do
77 plug(:accepts, ["html"])
79 plug(Pleroma.Plugs.OAuthPlug)
80 plug(Pleroma.Plugs.BasicAuthDecoderPlug)
81 plug(Pleroma.Plugs.UserFetcherPlug)
82 plug(Pleroma.Plugs.SessionAuthenticationPlug)
83 plug(Pleroma.Plugs.AuthenticationPlug)
84 plug(Pleroma.Plugs.EnsureUserKeyPlug)
87 pipeline :oauth_read_or_unauthenticated do
88 plug(Pleroma.Plugs.OAuthScopesPlug, %{
90 fallback: :proceed_unauthenticated
94 pipeline :oauth_read do
95 plug(Pleroma.Plugs.OAuthScopesPlug, %{scopes: ["read"]})
98 pipeline :oauth_write do
99 plug(Pleroma.Plugs.OAuthScopesPlug, %{scopes: ["write"]})
102 pipeline :oauth_follow do
103 plug(Pleroma.Plugs.OAuthScopesPlug, %{scopes: ["follow"]})
106 pipeline :oauth_push do
107 plug(Pleroma.Plugs.OAuthScopesPlug, %{scopes: ["push"]})
110 pipeline :well_known do
111 plug(:accepts, ["json", "jrd+json", "xml", "xrd+xml"])
115 plug(:accepts, ["json", "xml"])
118 pipeline :pleroma_api do
119 plug(:accepts, ["html", "json"])
122 pipeline :mailbox_preview do
123 plug(:accepts, ["html"])
125 plug(:put_secure_browser_headers, %{
126 "content-security-policy" =>
127 "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline' 'unsafe-eval'"
131 scope "/api/pleroma", Pleroma.Web.TwitterAPI do
132 pipe_through(:pleroma_api)
134 get("/password_reset/:token", UtilController, :show_password_reset)
135 post("/password_reset", UtilController, :password_reset)
136 get("/emoji", UtilController, :emoji)
137 get("/captcha", UtilController, :captcha)
140 scope "/api/pleroma", Pleroma.Web do
141 pipe_through(:pleroma_api)
142 post("/uploader_callback/:upload_path", UploaderController, :callback)
145 scope "/api/pleroma/admin", Pleroma.Web.AdminAPI do
146 pipe_through([:admin_api, :oauth_write])
148 post("/user/follow", AdminAPIController, :user_follow)
149 post("/user/unfollow", AdminAPIController, :user_unfollow)
151 get("/users", AdminAPIController, :list_users)
152 get("/users/:nickname", AdminAPIController, :user_show)
154 delete("/user", AdminAPIController, :user_delete)
155 patch("/users/:nickname/toggle_activation", AdminAPIController, :user_toggle_activation)
156 post("/user", AdminAPIController, :user_create)
157 put("/users/tag", AdminAPIController, :tag_users)
158 delete("/users/tag", AdminAPIController, :untag_users)
160 get("/permission_group/:nickname", AdminAPIController, :right_get)
161 get("/permission_group/:nickname/:permission_group", AdminAPIController, :right_get)
162 post("/permission_group/:nickname/:permission_group", AdminAPIController, :right_add)
163 delete("/permission_group/:nickname/:permission_group", AdminAPIController, :right_delete)
165 put("/activation_status/:nickname", AdminAPIController, :set_activation_status)
167 post("/relay", AdminAPIController, :relay_follow)
168 delete("/relay", AdminAPIController, :relay_unfollow)
170 get("/invite_token", AdminAPIController, :get_invite_token)
171 get("/invites", AdminAPIController, :invites)
172 post("/revoke_invite", AdminAPIController, :revoke_invite)
173 post("/email_invite", AdminAPIController, :email_invite)
175 get("/password_reset", AdminAPIController, :get_password_reset)
178 scope "/", Pleroma.Web.TwitterAPI do
179 pipe_through(:pleroma_html)
181 post("/main/ostatus", UtilController, :remote_subscribe)
182 get("/ostatus_subscribe", UtilController, :remote_follow)
185 pipe_through(:oauth_follow)
186 post("/ostatus_subscribe", UtilController, :do_remote_follow)
190 scope "/api/pleroma", Pleroma.Web.TwitterAPI do
191 pipe_through(:authenticated_api)
194 pipe_through(:oauth_write)
196 post("/change_password", UtilController, :change_password)
197 post("/delete_account", UtilController, :delete_account)
198 put("/notification_settings", UtilController, :update_notificaton_settings)
202 pipe_through(:oauth_follow)
204 post("/blocks_import", UtilController, :blocks_import)
205 post("/follow_import", UtilController, :follow_import)
209 pipe_through(:oauth_read)
211 post("/notifications/read", UtilController, :notifications_read)
215 scope "/oauth", Pleroma.Web.OAuth do
218 get("/authorize", OAuthController, :authorize)
221 post("/authorize", OAuthController, :create_authorization)
222 post("/token", OAuthController, :token_exchange)
223 post("/revoke", OAuthController, :token_revoke)
224 get("/registration_details", OAuthController, :registration_details)
227 pipe_through(:browser)
229 get("/prepare_request", OAuthController, :prepare_request)
230 get("/:provider", OAuthController, :request)
231 get("/:provider/callback", OAuthController, :callback)
232 post("/register", OAuthController, :register)
236 scope "/api/v1", Pleroma.Web.MastodonAPI do
237 pipe_through(:authenticated_api)
240 pipe_through(:oauth_read)
242 get("/accounts/verify_credentials", MastodonAPIController, :verify_credentials)
244 get("/accounts/relationships", MastodonAPIController, :relationships)
245 get("/accounts/search", MastodonAPIController, :account_search)
247 get("/accounts/:id/lists", MastodonAPIController, :account_lists)
248 get("/accounts/:id/identity_proofs", MastodonAPIController, :empty_array)
250 get("/follow_requests", MastodonAPIController, :follow_requests)
251 get("/blocks", MastodonAPIController, :blocks)
252 get("/mutes", MastodonAPIController, :mutes)
254 get("/timelines/home", MastodonAPIController, :home_timeline)
255 get("/timelines/direct", MastodonAPIController, :dm_timeline)
257 get("/favourites", MastodonAPIController, :favourites)
258 get("/bookmarks", MastodonAPIController, :bookmarks)
260 post("/notifications/clear", MastodonAPIController, :clear_notifications)
261 post("/notifications/dismiss", MastodonAPIController, :dismiss_notification)
262 get("/notifications", MastodonAPIController, :notifications)
263 get("/notifications/:id", MastodonAPIController, :get_notification)
264 delete("/notifications/destroy_multiple", MastodonAPIController, :destroy_multiple)
266 get("/scheduled_statuses", MastodonAPIController, :scheduled_statuses)
267 get("/scheduled_statuses/:id", MastodonAPIController, :show_scheduled_status)
269 get("/lists", MastodonAPIController, :get_lists)
270 get("/lists/:id", MastodonAPIController, :get_list)
271 get("/lists/:id/accounts", MastodonAPIController, :list_accounts)
273 get("/domain_blocks", MastodonAPIController, :domain_blocks)
275 get("/filters", MastodonAPIController, :get_filters)
277 get("/suggestions", MastodonAPIController, :suggestions)
279 get("/endorsements", MastodonAPIController, :empty_array)
281 get("/pleroma/flavour", MastodonAPIController, :get_flavour)
285 pipe_through(:oauth_write)
287 patch("/accounts/update_credentials", MastodonAPIController, :update_credentials)
289 post("/statuses", MastodonAPIController, :post_status)
290 delete("/statuses/:id", MastodonAPIController, :delete_status)
292 post("/statuses/:id/reblog", MastodonAPIController, :reblog_status)
293 post("/statuses/:id/unreblog", MastodonAPIController, :unreblog_status)
294 post("/statuses/:id/favourite", MastodonAPIController, :fav_status)
295 post("/statuses/:id/unfavourite", MastodonAPIController, :unfav_status)
296 post("/statuses/:id/pin", MastodonAPIController, :pin_status)
297 post("/statuses/:id/unpin", MastodonAPIController, :unpin_status)
298 post("/statuses/:id/bookmark", MastodonAPIController, :bookmark_status)
299 post("/statuses/:id/unbookmark", MastodonAPIController, :unbookmark_status)
300 post("/statuses/:id/mute", MastodonAPIController, :mute_conversation)
301 post("/statuses/:id/unmute", MastodonAPIController, :unmute_conversation)
303 put("/scheduled_statuses/:id", MastodonAPIController, :update_scheduled_status)
304 delete("/scheduled_statuses/:id", MastodonAPIController, :delete_scheduled_status)
306 post("/media", MastodonAPIController, :upload)
307 put("/media/:id", MastodonAPIController, :update_media)
309 delete("/lists/:id", MastodonAPIController, :delete_list)
310 post("/lists", MastodonAPIController, :create_list)
311 put("/lists/:id", MastodonAPIController, :rename_list)
313 post("/lists/:id/accounts", MastodonAPIController, :add_to_list)
314 delete("/lists/:id/accounts", MastodonAPIController, :remove_from_list)
316 post("/filters", MastodonAPIController, :create_filter)
317 get("/filters/:id", MastodonAPIController, :get_filter)
318 put("/filters/:id", MastodonAPIController, :update_filter)
319 delete("/filters/:id", MastodonAPIController, :delete_filter)
321 post("/pleroma/flavour/:flavour", MastodonAPIController, :set_flavour)
323 post("/reports", MastodonAPIController, :reports)
327 pipe_through(:oauth_follow)
329 post("/follows", MastodonAPIController, :follow)
330 post("/accounts/:id/follow", MastodonAPIController, :follow)
332 post("/accounts/:id/unfollow", MastodonAPIController, :unfollow)
333 post("/accounts/:id/block", MastodonAPIController, :block)
334 post("/accounts/:id/unblock", MastodonAPIController, :unblock)
335 post("/accounts/:id/mute", MastodonAPIController, :mute)
336 post("/accounts/:id/unmute", MastodonAPIController, :unmute)
338 post("/follow_requests/:id/authorize", MastodonAPIController, :authorize_follow_request)
339 post("/follow_requests/:id/reject", MastodonAPIController, :reject_follow_request)
341 post("/domain_blocks", MastodonAPIController, :block_domain)
342 delete("/domain_blocks", MastodonAPIController, :unblock_domain)
344 post("/pleroma/accounts/:id/subscribe", MastodonAPIController, :subscribe)
345 post("/pleroma/accounts/:id/unsubscribe", MastodonAPIController, :unsubscribe)
349 pipe_through(:oauth_push)
351 post("/push/subscription", SubscriptionController, :create)
352 get("/push/subscription", SubscriptionController, :get)
353 put("/push/subscription", SubscriptionController, :update)
354 delete("/push/subscription", SubscriptionController, :delete)
358 scope "/api/web", Pleroma.Web.MastodonAPI do
359 pipe_through([:authenticated_api, :oauth_write])
361 put("/settings", MastodonAPIController, :put_settings)
364 scope "/api/v1", Pleroma.Web.MastodonAPI do
367 get("/instance", MastodonAPIController, :masto_instance)
368 get("/instance/peers", MastodonAPIController, :peers)
369 post("/apps", MastodonAPIController, :create_app)
370 get("/apps/verify_credentials", MastodonAPIController, :verify_app_credentials)
371 get("/custom_emojis", MastodonAPIController, :custom_emojis)
373 get("/statuses/:id/card", MastodonAPIController, :status_card)
375 get("/statuses/:id/favourited_by", MastodonAPIController, :favourited_by)
376 get("/statuses/:id/reblogged_by", MastodonAPIController, :reblogged_by)
378 get("/trends", MastodonAPIController, :empty_array)
381 pipe_through(:oauth_read_or_unauthenticated)
383 get("/timelines/public", MastodonAPIController, :public_timeline)
384 get("/timelines/tag/:tag", MastodonAPIController, :hashtag_timeline)
385 get("/timelines/list/:list_id", MastodonAPIController, :list_timeline)
387 get("/statuses/:id", MastodonAPIController, :get_status)
388 get("/statuses/:id/context", MastodonAPIController, :get_context)
390 get("/accounts/:id/statuses", MastodonAPIController, :user_statuses)
391 get("/accounts/:id/followers", MastodonAPIController, :followers)
392 get("/accounts/:id/following", MastodonAPIController, :following)
393 get("/accounts/:id", MastodonAPIController, :user)
395 get("/search", MastodonAPIController, :search)
399 scope "/api/v2", Pleroma.Web.MastodonAPI do
400 pipe_through([:api, :oauth_read_or_unauthenticated])
401 get("/search", MastodonAPIController, :search2)
404 scope "/api", Pleroma.Web do
405 pipe_through(:config)
407 get("/help/test", TwitterAPI.UtilController, :help_test)
408 post("/help/test", TwitterAPI.UtilController, :help_test)
409 get("/statusnet/config", TwitterAPI.UtilController, :config)
410 get("/statusnet/version", TwitterAPI.UtilController, :version)
411 get("/pleroma/frontend_configurations", TwitterAPI.UtilController, :frontend_configurations)
414 scope "/api", Pleroma.Web do
417 post("/account/register", TwitterAPI.Controller, :register)
418 post("/account/password_reset", TwitterAPI.Controller, :password_reset)
420 post("/account/resend_confirmation_email", TwitterAPI.Controller, :resend_confirmation_email)
423 "/account/confirm_email/:user_id/:token",
424 TwitterAPI.Controller,
430 pipe_through(:oauth_read_or_unauthenticated)
432 get("/statuses/user_timeline", TwitterAPI.Controller, :user_timeline)
433 get("/qvitter/statuses/user_timeline", TwitterAPI.Controller, :user_timeline)
434 get("/users/show", TwitterAPI.Controller, :show_user)
436 get("/statuses/followers", TwitterAPI.Controller, :followers)
437 get("/statuses/friends", TwitterAPI.Controller, :friends)
438 get("/statuses/blocks", TwitterAPI.Controller, :blocks)
439 get("/statuses/show/:id", TwitterAPI.Controller, :fetch_status)
440 get("/statusnet/conversation/:id", TwitterAPI.Controller, :fetch_conversation)
442 get("/search", TwitterAPI.Controller, :search)
443 get("/statusnet/tags/timeline/:tag", TwitterAPI.Controller, :public_and_external_timeline)
447 scope "/api", Pleroma.Web do
448 pipe_through([:api, :oauth_read_or_unauthenticated])
450 get("/statuses/public_timeline", TwitterAPI.Controller, :public_timeline)
453 "/statuses/public_and_external_timeline",
454 TwitterAPI.Controller,
455 :public_and_external_timeline
458 get("/statuses/networkpublic_timeline", TwitterAPI.Controller, :public_and_external_timeline)
461 scope "/api", Pleroma.Web, as: :twitter_api_search do
462 pipe_through([:api, :oauth_read_or_unauthenticated])
463 get("/pleroma/search_user", TwitterAPI.Controller, :search_user)
466 scope "/api", Pleroma.Web, as: :authenticated_twitter_api do
467 pipe_through(:authenticated_api)
469 get("/oauth_tokens", TwitterAPI.Controller, :oauth_tokens)
470 delete("/oauth_tokens/:id", TwitterAPI.Controller, :revoke_token)
473 pipe_through(:oauth_read)
475 get("/account/verify_credentials", TwitterAPI.Controller, :verify_credentials)
476 post("/account/verify_credentials", TwitterAPI.Controller, :verify_credentials)
478 get("/statuses/home_timeline", TwitterAPI.Controller, :friends_timeline)
479 get("/statuses/friends_timeline", TwitterAPI.Controller, :friends_timeline)
480 get("/statuses/mentions", TwitterAPI.Controller, :mentions_timeline)
481 get("/statuses/mentions_timeline", TwitterAPI.Controller, :mentions_timeline)
482 get("/statuses/dm_timeline", TwitterAPI.Controller, :dm_timeline)
483 get("/qvitter/statuses/notifications", TwitterAPI.Controller, :notifications)
485 get("/pleroma/friend_requests", TwitterAPI.Controller, :friend_requests)
487 get("/friends/ids", TwitterAPI.Controller, :friends_ids)
488 get("/friendships/no_retweets/ids", TwitterAPI.Controller, :empty_array)
490 get("/mutes/users/ids", TwitterAPI.Controller, :empty_array)
491 get("/qvitter/mutes", TwitterAPI.Controller, :raw_empty_array)
493 get("/externalprofile/show", TwitterAPI.Controller, :external_profile)
495 post("/qvitter/statuses/notifications/read", TwitterAPI.Controller, :notifications_read)
499 pipe_through(:oauth_write)
501 post("/account/update_profile", TwitterAPI.Controller, :update_profile)
502 post("/account/update_profile_banner", TwitterAPI.Controller, :update_banner)
503 post("/qvitter/update_background_image", TwitterAPI.Controller, :update_background)
505 post("/statuses/update", TwitterAPI.Controller, :status_update)
506 post("/statuses/retweet/:id", TwitterAPI.Controller, :retweet)
507 post("/statuses/unretweet/:id", TwitterAPI.Controller, :unretweet)
508 post("/statuses/destroy/:id", TwitterAPI.Controller, :delete_post)
510 post("/statuses/pin/:id", TwitterAPI.Controller, :pin)
511 post("/statuses/unpin/:id", TwitterAPI.Controller, :unpin)
513 post("/statusnet/media/upload", TwitterAPI.Controller, :upload)
514 post("/media/upload", TwitterAPI.Controller, :upload_json)
515 post("/media/metadata/create", TwitterAPI.Controller, :update_media)
517 post("/favorites/create/:id", TwitterAPI.Controller, :favorite)
518 post("/favorites/create", TwitterAPI.Controller, :favorite)
519 post("/favorites/destroy/:id", TwitterAPI.Controller, :unfavorite)
521 post("/qvitter/update_avatar", TwitterAPI.Controller, :update_avatar)
525 pipe_through(:oauth_follow)
527 post("/pleroma/friendships/approve", TwitterAPI.Controller, :approve_friend_request)
528 post("/pleroma/friendships/deny", TwitterAPI.Controller, :deny_friend_request)
530 post("/friendships/create", TwitterAPI.Controller, :follow)
531 post("/friendships/destroy", TwitterAPI.Controller, :unfollow)
533 post("/blocks/create", TwitterAPI.Controller, :block)
534 post("/blocks/destroy", TwitterAPI.Controller, :unblock)
538 pipeline :ap_relay do
539 plug(:accepts, ["activity+json", "json"])
543 plug(:accepts, ["html", "xml", "atom", "activity+json", "json"])
547 plug(:accepts, ["json", "xml"])
550 scope "/", Pleroma.Web do
551 pipe_through(:ostatus)
553 get("/objects/:uuid", OStatus.OStatusController, :object)
554 get("/activities/:uuid", OStatus.OStatusController, :activity)
555 get("/notice/:id", OStatus.OStatusController, :notice)
556 get("/notice/:id/embed_player", OStatus.OStatusController, :notice_player)
557 get("/users/:nickname/feed", OStatus.OStatusController, :feed)
558 get("/users/:nickname", OStatus.OStatusController, :feed_redirect)
560 post("/users/:nickname/salmon", OStatus.OStatusController, :salmon_incoming)
561 post("/push/hub/:nickname", Websub.WebsubController, :websub_subscription_request)
562 get("/push/subscriptions/:id", Websub.WebsubController, :websub_subscription_confirmation)
563 post("/push/subscriptions/:id", Websub.WebsubController, :websub_incoming)
566 scope "/", Pleroma.Web do
567 pipe_through(:oembed)
569 get("/oembed", OEmbed.OEmbedController, :url)
572 pipeline :activitypub do
573 plug(:accepts, ["activity+json", "json"])
574 plug(Pleroma.Web.Plugs.HTTPSignaturePlug)
577 scope "/", Pleroma.Web.ActivityPub do
578 # XXX: not really ostatus
579 pipe_through(:ostatus)
581 get("/users/:nickname/followers", ActivityPubController, :followers)
582 get("/users/:nickname/following", ActivityPubController, :following)
583 get("/users/:nickname/outbox", ActivityPubController, :outbox)
584 get("/objects/:uuid/likes", ActivityPubController, :object_likes)
587 pipeline :activitypub_client do
588 plug(:accepts, ["activity+json", "json"])
590 plug(Pleroma.Plugs.OAuthPlug)
591 plug(Pleroma.Plugs.BasicAuthDecoderPlug)
592 plug(Pleroma.Plugs.UserFetcherPlug)
593 plug(Pleroma.Plugs.SessionAuthenticationPlug)
594 plug(Pleroma.Plugs.LegacyAuthenticationPlug)
595 plug(Pleroma.Plugs.AuthenticationPlug)
596 plug(Pleroma.Plugs.UserEnabledPlug)
597 plug(Pleroma.Plugs.SetUserSessionIdPlug)
598 plug(Pleroma.Plugs.EnsureUserKeyPlug)
601 scope "/", Pleroma.Web.ActivityPub do
602 pipe_through([:activitypub_client])
605 pipe_through(:oauth_read)
606 get("/api/ap/whoami", ActivityPubController, :whoami)
607 get("/users/:nickname/inbox", ActivityPubController, :read_inbox)
611 pipe_through(:oauth_write)
612 post("/users/:nickname/outbox", ActivityPubController, :update_outbox)
616 scope "/relay", Pleroma.Web.ActivityPub do
617 pipe_through(:ap_relay)
618 get("/", ActivityPubController, :relay)
621 scope "/", Pleroma.Web.ActivityPub do
622 pipe_through(:activitypub)
623 post("/inbox", ActivityPubController, :inbox)
624 post("/users/:nickname/inbox", ActivityPubController, :inbox)
627 scope "/.well-known", Pleroma.Web do
628 pipe_through(:well_known)
630 get("/host-meta", WebFinger.WebFingerController, :host_meta)
631 get("/webfinger", WebFinger.WebFingerController, :webfinger)
632 get("/nodeinfo", Nodeinfo.NodeinfoController, :schemas)
635 scope "/nodeinfo", Pleroma.Web do
636 get("/:version", Nodeinfo.NodeinfoController, :nodeinfo)
639 scope "/", Pleroma.Web.MastodonAPI do
640 pipe_through(:mastodon_html)
642 get("/web/login", MastodonAPIController, :login)
643 delete("/auth/sign_out", MastodonAPIController, :logout)
646 pipe_through(:oauth_read_or_unauthenticated)
647 get("/web/*path", MastodonAPIController, :index)
651 pipeline :remote_media do
654 scope "/proxy/", Pleroma.Web.MediaProxy do
655 pipe_through(:remote_media)
657 get("/:sig/:url", MediaProxyController, :remote)
658 get("/:sig/:url/:filename", MediaProxyController, :remote)
661 if Mix.env() == :dev do
663 pipe_through([:mailbox_preview])
665 forward("/mailbox", Plug.Swoosh.MailboxPreview, base_path: "/dev/mailbox")
669 scope "/", Fallback do
670 get("/registration/:token", RedirectController, :registration_page)
671 get("/:maybe_nickname_or_id", RedirectController, :redirector_with_meta)
672 get("/*path", RedirectController, :redirector)
674 options("/*path", RedirectController, :empty)
678 defmodule Fallback.RedirectController do
679 use Pleroma.Web, :controller
681 alias Pleroma.Web.Metadata
683 def redirector(conn, _params, code \\ 200) do
685 |> put_resp_content_type("text/html")
686 |> send_file(code, index_file_path())
689 def redirector_with_meta(conn, %{"maybe_nickname_or_id" => maybe_nickname_or_id} = params) do
690 with %User{} = user <- User.get_cached_by_nickname_or_id(maybe_nickname_or_id) do
691 redirector_with_meta(conn, %{user: user})
694 redirector(conn, params)
698 def redirector_with_meta(conn, params) do
699 {:ok, index_content} = File.read(index_file_path())
700 tags = Metadata.build_tags(params)
701 response = String.replace(index_content, "<!--server-generated-meta-->", tags)
704 |> put_resp_content_type("text/html")
705 |> send_resp(200, response)
708 def index_file_path do
709 Pleroma.Plugs.InstanceStatic.file_path("index.html")
712 def registration_page(conn, params) do
713 redirector(conn, params)
716 def empty(conn, _params) do