1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.Router do
6 use Pleroma.Web, :router
8 pipeline :accepts_html do
9 plug(:accepts, ["html"])
12 pipeline :accepts_html_xml do
13 plug(:accepts, ["html", "xml", "rss", "atom"])
16 pipeline :accepts_html_json do
17 plug(:accepts, ["html", "activity+json", "json"])
20 pipeline :accepts_html_xml_json do
21 plug(:accepts, ["html", "xml", "rss", "atom", "activity+json", "json"])
24 pipeline :accepts_xml_rss_atom do
25 plug(:accepts, ["xml", "rss", "atom"])
29 plug(:accepts, ["html"])
35 plug(Pleroma.Web.Plugs.OAuthPlug)
36 plug(Pleroma.Web.Plugs.UserEnabledPlug)
37 plug(Pleroma.Web.Plugs.EnsureUserTokenAssignsPlug)
40 # Note: expects _user_ authentication (user-unbound app-bound tokens don't qualify)
41 pipeline :expect_user_authentication do
42 plug(Pleroma.Web.Plugs.ExpectAuthenticatedCheckPlug)
45 # Note: expects public instance or _user_ authentication (user-unbound tokens don't qualify)
46 pipeline :expect_public_instance_or_user_authentication do
47 plug(Pleroma.Web.Plugs.ExpectPublicOrAuthenticatedCheckPlug)
50 pipeline :authenticate do
51 plug(Pleroma.Web.Plugs.OAuthPlug)
52 plug(Pleroma.Web.Plugs.BasicAuthDecoderPlug)
53 plug(Pleroma.Web.Plugs.UserFetcherPlug)
54 plug(Pleroma.Web.Plugs.AuthenticationPlug)
57 pipeline :after_auth do
58 plug(Pleroma.Web.Plugs.UserEnabledPlug)
59 plug(Pleroma.Web.Plugs.SetUserSessionIdPlug)
60 plug(Pleroma.Web.Plugs.EnsureUserTokenAssignsPlug)
61 plug(Pleroma.Web.Plugs.UserTrackingPlug)
65 plug(:accepts, ["json"])
68 plug(OpenApiSpex.Plug.PutApiSpec, module: Pleroma.Web.ApiSpec)
71 pipeline :no_auth_or_privacy_expectations_api do
74 plug(Pleroma.Web.Plugs.IdempotencyPlug)
77 # Pipeline for app-related endpoints (no user auth checks — app-bound tokens must be supported)
79 plug(:no_auth_or_privacy_expectations_api)
83 plug(:expect_public_instance_or_user_authentication)
84 plug(:no_auth_or_privacy_expectations_api)
87 pipeline :authenticated_api do
88 plug(:expect_user_authentication)
89 plug(:no_auth_or_privacy_expectations_api)
90 plug(Pleroma.Web.Plugs.EnsureAuthenticatedPlug)
93 pipeline :admin_api do
94 plug(:expect_user_authentication)
96 plug(Pleroma.Web.Plugs.AdminSecretAuthenticationPlug)
98 plug(Pleroma.Web.Plugs.EnsureAuthenticatedPlug)
99 plug(Pleroma.Web.Plugs.UserIsAdminPlug)
100 plug(Pleroma.Web.Plugs.IdempotencyPlug)
103 pipeline :mastodon_html do
109 pipeline :pleroma_html do
112 plug(Pleroma.Web.Plugs.EnsureUserTokenAssignsPlug)
115 pipeline :well_known do
116 plug(:accepts, ["json", "jrd+json", "xml", "xrd+xml"])
120 plug(:accepts, ["json", "xml"])
121 plug(OpenApiSpex.Plug.PutApiSpec, module: Pleroma.Web.ApiSpec)
124 pipeline :pleroma_api do
125 plug(:accepts, ["html", "json"])
126 plug(OpenApiSpex.Plug.PutApiSpec, module: Pleroma.Web.ApiSpec)
129 pipeline :mailbox_preview do
130 plug(:accepts, ["html"])
132 plug(:put_secure_browser_headers, %{
133 "content-security-policy" =>
134 "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline' 'unsafe-eval'"
138 pipeline :http_signature do
139 plug(Pleroma.Web.Plugs.HTTPSignaturePlug)
140 plug(Pleroma.Web.Plugs.MappedSignatureToIdentityPlug)
143 pipeline :static_fe do
144 plug(Pleroma.Web.Plugs.StaticFEPlug)
147 scope "/api/v1/pleroma", Pleroma.Web.TwitterAPI do
148 pipe_through(:pleroma_api)
150 get("/password_reset/:token", PasswordController, :reset, as: :reset_password)
151 post("/password_reset", PasswordController, :do_reset, as: :reset_password)
152 get("/emoji", UtilController, :emoji)
153 get("/captcha", UtilController, :captcha)
154 get("/healthcheck", UtilController, :healthcheck)
157 scope "/api/v1/pleroma", Pleroma.Web do
158 pipe_through(:pleroma_api)
159 post("/uploader_callback/:upload_path", UploaderController, :callback)
162 scope "/api/v1/pleroma/admin", Pleroma.Web.AdminAPI do
163 pipe_through(:admin_api)
165 put("/users/disable_mfa", AdminAPIController, :disable_mfa)
166 put("/users/tag", AdminAPIController, :tag_users)
167 delete("/users/tag", AdminAPIController, :untag_users)
169 get("/users/:nickname/permission_group", AdminAPIController, :right_get)
170 get("/users/:nickname/permission_group/:permission_group", AdminAPIController, :right_get)
172 post("/users/:nickname/permission_group/:permission_group", AdminAPIController, :right_add)
175 "/users/:nickname/permission_group/:permission_group",
180 post("/users/permission_group/:permission_group", AdminAPIController, :right_add_multiple)
183 "/users/permission_group/:permission_group",
185 :right_delete_multiple
188 post("/users/follow", UserController, :follow)
189 post("/users/unfollow", UserController, :unfollow)
190 delete("/users", UserController, :delete)
191 post("/users", UserController, :create)
192 patch("/users/:nickname/toggle_activation", UserController, :toggle_activation)
193 patch("/users/activate", UserController, :activate)
194 patch("/users/deactivate", UserController, :deactivate)
195 patch("/users/approve", UserController, :approve)
197 get("/relay", RelayController, :index)
198 post("/relay", RelayController, :follow)
199 delete("/relay", RelayController, :unfollow)
201 post("/users/invite_token", InviteController, :create)
202 get("/users/invites", InviteController, :index)
203 post("/users/revoke_invite", InviteController, :revoke)
204 post("/users/email_invite", InviteController, :email)
206 get("/users/:nickname/password_reset", AdminAPIController, :get_password_reset)
207 patch("/users/force_password_reset", AdminAPIController, :force_password_reset)
208 get("/users/:nickname/credentials", AdminAPIController, :show_user_credentials)
209 patch("/users/:nickname/credentials", AdminAPIController, :update_user_credentials)
211 get("/users", UserController, :index)
212 get("/users/:nickname", UserController, :show)
213 get("/users/:nickname/statuses", AdminAPIController, :list_user_statuses)
214 get("/users/:nickname/chats", AdminAPIController, :list_user_chats)
216 get("/instances/:instance/statuses", AdminAPIController, :list_instance_statuses)
218 get("/instance_document/:name", InstanceDocumentController, :show)
219 patch("/instance_document/:name", InstanceDocumentController, :update)
220 delete("/instance_document/:name", InstanceDocumentController, :delete)
222 patch("/users/confirm_email", AdminAPIController, :confirm_email)
223 patch("/users/resend_confirmation_email", AdminAPIController, :resend_confirmation_email)
225 get("/reports", ReportController, :index)
226 get("/reports/:id", ReportController, :show)
227 patch("/reports", ReportController, :update)
228 post("/reports/:id/notes", ReportController, :notes_create)
229 delete("/reports/:report_id/notes/:id", ReportController, :notes_delete)
231 get("/statuses/:id", StatusController, :show)
232 put("/statuses/:id", StatusController, :update)
233 delete("/statuses/:id", StatusController, :delete)
234 get("/statuses", StatusController, :index)
236 get("/config", ConfigController, :show)
237 post("/config", ConfigController, :update)
238 get("/config/descriptions", ConfigController, :descriptions)
239 get("/need_reboot", AdminAPIController, :need_reboot)
240 get("/restart", AdminAPIController, :restart)
242 get("/moderation_log", AdminAPIController, :list_log)
244 post("/reload_emoji", AdminAPIController, :reload_emoji)
245 get("/stats", AdminAPIController, :stats)
247 get("/oauth_app", OAuthAppController, :index)
248 post("/oauth_app", OAuthAppController, :create)
249 patch("/oauth_app/:id", OAuthAppController, :update)
250 delete("/oauth_app/:id", OAuthAppController, :delete)
252 get("/media_proxy_caches", MediaProxyCacheController, :index)
253 post("/media_proxy_caches/delete", MediaProxyCacheController, :delete)
254 post("/media_proxy_caches/purge", MediaProxyCacheController, :purge)
256 get("/chats/:id", ChatController, :show)
257 get("/chats/:id/messages", ChatController, :messages)
258 delete("/chats/:id/messages/:message_id", ChatController, :delete_message)
260 get("/frontends", FrontendController, :index)
261 post("/frontends/install", FrontendController, :install)
263 post("/backups", AdminAPIController, :create_backup)
266 scope "/api/v1/pleroma/emoji", Pleroma.Web.PleromaAPI do
268 pipe_through(:admin_api)
270 post("/", EmojiPackController, :create)
271 patch("/", EmojiPackController, :update)
272 delete("/", EmojiPackController, :delete)
278 get("/", EmojiPackController, :show)
283 pipe_through(:admin_api)
285 get("/import", EmojiPackController, :import_from_filesystem)
286 get("/remote", EmojiPackController, :remote)
287 post("/download", EmojiPackController, :download)
289 post("/files", EmojiFileController, :create)
290 patch("/files", EmojiFileController, :update)
291 delete("/files", EmojiFileController, :delete)
294 # Pack info / downloading
298 get("/", EmojiPackController, :index)
299 get("/archive", EmojiPackController, :archive)
303 scope "/", Pleroma.Web.TwitterAPI do
304 pipe_through(:pleroma_html)
306 post("/main/ostatus", UtilController, :remote_subscribe)
307 get("/ostatus_subscribe", RemoteFollowController, :follow)
308 post("/ostatus_subscribe", RemoteFollowController, :do_follow)
311 scope "/api/pleroma", Pleroma.Web.TwitterAPI do
312 pipe_through(:authenticated_api)
314 post("/change_email", UtilController, :change_email)
315 post("/change_password", UtilController, :change_password)
316 post("/delete_account", UtilController, :delete_account)
317 put("/notification_settings", UtilController, :update_notificaton_settings)
318 post("/disable_account", UtilController, :disable_account)
321 scope "/api/pleroma", Pleroma.Web.PleromaAPI do
322 pipe_through(:authenticated_api)
324 post("/mutes_import", UserImportController, :mutes)
325 post("/blocks_import", UserImportController, :blocks)
326 post("/follow_import", UserImportController, :follow)
328 get("/accounts/mfa", TwoFactorAuthenticationController, :settings)
329 get("/accounts/mfa/backup_codes", TwoFactorAuthenticationController, :backup_codes)
330 get("/accounts/mfa/setup/:method", TwoFactorAuthenticationController, :setup)
331 post("/accounts/mfa/confirm/:method", TwoFactorAuthenticationController, :confirm)
332 delete("/accounts/mfa/:method", TwoFactorAuthenticationController, :disable)
335 scope "/oauth", Pleroma.Web.OAuth do
336 # Note: use /api/v1/accounts/verify_credentials for userinfo of signed-in user
338 get("/registration_details", OAuthController, :registration_details)
340 post("/mfa/verify", MFAController, :verify, as: :mfa_verify)
341 get("/mfa", MFAController, :show)
346 get("/authorize", OAuthController, :authorize)
347 post("/authorize", OAuthController, :create_authorization)
351 pipe_through(:fetch_session)
353 post("/token", OAuthController, :token_exchange)
354 post("/revoke", OAuthController, :token_revoke)
355 post("/mfa/challenge", MFAController, :challenge)
359 pipe_through(:browser)
361 get("/prepare_request", OAuthController, :prepare_request)
362 get("/:provider", OAuthController, :request)
363 get("/:provider/callback", OAuthController, :callback)
364 post("/register", OAuthController, :register)
368 scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do
371 get("/statuses/:id/reactions/:emoji", EmojiReactionController, :index)
372 get("/statuses/:id/reactions", EmojiReactionController, :index)
375 scope "/api/v0/pleroma", Pleroma.Web.PleromaAPI do
376 pipe_through(:authenticated_api)
377 get("/reports", ReportController, :index)
378 get("/reports/:id", ReportController, :show)
381 scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do
383 pipe_through(:authenticated_api)
385 post("/chats/by-account-id/:id", ChatController, :create)
386 get("/chats", ChatController, :index)
387 get("/chats/:id", ChatController, :show)
388 get("/chats/:id/messages", ChatController, :messages)
389 post("/chats/:id/messages", ChatController, :post_chat_message)
390 delete("/chats/:id/messages/:message_id", ChatController, :delete_message)
391 post("/chats/:id/read", ChatController, :mark_as_read)
392 post("/chats/:id/messages/:message_id/read", ChatController, :mark_message_as_read)
394 get("/conversations/:id/statuses", ConversationController, :statuses)
395 get("/conversations/:id", ConversationController, :show)
396 post("/conversations/read", ConversationController, :mark_as_read)
397 patch("/conversations/:id", ConversationController, :update)
399 put("/statuses/:id/reactions/:emoji", EmojiReactionController, :create)
400 delete("/statuses/:id/reactions/:emoji", EmojiReactionController, :delete)
401 post("/notifications/read", NotificationController, :mark_as_read)
403 get("/mascot", MascotController, :show)
404 put("/mascot", MascotController, :update)
406 post("/scrobble", ScrobbleController, :create)
408 get("/backups", BackupController, :index)
409 post("/backups", BackupController, :create)
414 get("/accounts/:id/favourites", AccountController, :favourites)
418 pipe_through(:authenticated_api)
420 post("/accounts/:id/subscribe", AccountController, :subscribe)
421 post("/accounts/:id/unsubscribe", AccountController, :unsubscribe)
424 post("/accounts/confirmation_resend", AccountController, :confirmation_resend)
427 scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do
429 get("/accounts/:id/scrobbles", ScrobbleController, :index)
430 get("/federation_status", InstancesController, :show)
433 scope "/api/v2/pleroma", Pleroma.Web.PleromaAPI do
435 pipe_through(:authenticated_api)
436 get("/chats", ChatController, :index2)
440 scope "/api/v1", Pleroma.Web.MastodonAPI do
441 pipe_through(:authenticated_api)
443 get("/accounts/verify_credentials", AccountController, :verify_credentials)
444 patch("/accounts/update_credentials", AccountController, :update_credentials)
446 get("/accounts/relationships", AccountController, :relationships)
447 get("/accounts/:id/lists", AccountController, :lists)
448 get("/accounts/:id/identity_proofs", AccountController, :identity_proofs)
449 get("/endorsements", AccountController, :endorsements)
450 get("/blocks", AccountController, :blocks)
451 get("/mutes", AccountController, :mutes)
453 post("/follows", AccountController, :follow_by_uri)
454 post("/accounts/:id/follow", AccountController, :follow)
455 post("/accounts/:id/unfollow", AccountController, :unfollow)
456 post("/accounts/:id/block", AccountController, :block)
457 post("/accounts/:id/unblock", AccountController, :unblock)
458 post("/accounts/:id/mute", AccountController, :mute)
459 post("/accounts/:id/unmute", AccountController, :unmute)
461 get("/conversations", ConversationController, :index)
462 post("/conversations/:id/read", ConversationController, :mark_as_read)
463 delete("/conversations/:id", ConversationController, :delete)
465 get("/domain_blocks", DomainBlockController, :index)
466 post("/domain_blocks", DomainBlockController, :create)
467 delete("/domain_blocks", DomainBlockController, :delete)
469 get("/filters", FilterController, :index)
471 post("/filters", FilterController, :create)
472 get("/filters/:id", FilterController, :show)
473 put("/filters/:id", FilterController, :update)
474 delete("/filters/:id", FilterController, :delete)
476 get("/follow_requests", FollowRequestController, :index)
477 post("/follow_requests/:id/authorize", FollowRequestController, :authorize)
478 post("/follow_requests/:id/reject", FollowRequestController, :reject)
480 get("/lists", ListController, :index)
481 get("/lists/:id", ListController, :show)
482 get("/lists/:id/accounts", ListController, :list_accounts)
484 delete("/lists/:id", ListController, :delete)
485 post("/lists", ListController, :create)
486 put("/lists/:id", ListController, :update)
487 post("/lists/:id/accounts", ListController, :add_to_list)
488 delete("/lists/:id/accounts", ListController, :remove_from_list)
490 get("/markers", MarkerController, :index)
491 post("/markers", MarkerController, :upsert)
493 post("/media", MediaController, :create)
494 get("/media/:id", MediaController, :show)
495 put("/media/:id", MediaController, :update)
497 get("/notifications", NotificationController, :index)
498 get("/notifications/:id", NotificationController, :show)
500 post("/notifications/:id/dismiss", NotificationController, :dismiss)
501 post("/notifications/clear", NotificationController, :clear)
502 delete("/notifications/destroy_multiple", NotificationController, :destroy_multiple)
503 # Deprecated: was removed in Mastodon v3, use `/notifications/:id/dismiss` instead
504 post("/notifications/dismiss", NotificationController, :dismiss_via_body)
506 post("/polls/:id/votes", PollController, :vote)
508 post("/reports", ReportController, :create)
510 get("/scheduled_statuses", ScheduledActivityController, :index)
511 get("/scheduled_statuses/:id", ScheduledActivityController, :show)
513 put("/scheduled_statuses/:id", ScheduledActivityController, :update)
514 delete("/scheduled_statuses/:id", ScheduledActivityController, :delete)
516 # Unlike `GET /api/v1/accounts/:id/favourites`, demands authentication
517 get("/favourites", StatusController, :favourites)
518 get("/bookmarks", StatusController, :bookmarks)
520 post("/statuses", StatusController, :create)
521 delete("/statuses/:id", StatusController, :delete)
522 post("/statuses/:id/reblog", StatusController, :reblog)
523 post("/statuses/:id/unreblog", StatusController, :unreblog)
524 post("/statuses/:id/favourite", StatusController, :favourite)
525 post("/statuses/:id/unfavourite", StatusController, :unfavourite)
526 post("/statuses/:id/pin", StatusController, :pin)
527 post("/statuses/:id/unpin", StatusController, :unpin)
528 post("/statuses/:id/bookmark", StatusController, :bookmark)
529 post("/statuses/:id/unbookmark", StatusController, :unbookmark)
530 post("/statuses/:id/mute", StatusController, :mute_conversation)
531 post("/statuses/:id/unmute", StatusController, :unmute_conversation)
533 post("/push/subscription", SubscriptionController, :create)
534 get("/push/subscription", SubscriptionController, :show)
535 put("/push/subscription", SubscriptionController, :update)
536 delete("/push/subscription", SubscriptionController, :delete)
538 get("/suggestions", SuggestionController, :index)
540 get("/timelines/home", TimelineController, :home)
541 get("/timelines/direct", TimelineController, :direct)
542 get("/timelines/list/:list_id", TimelineController, :list)
545 scope "/api/web", Pleroma.Web do
546 pipe_through(:authenticated_api)
548 # Backend-obscure settings blob for MastoFE, don't parse/reuse elsewhere
549 put("/settings", MastoFEController, :put_settings)
552 scope "/api/v1", Pleroma.Web.MastodonAPI do
553 pipe_through(:app_api)
555 post("/apps", AppController, :create)
556 get("/apps/verify_credentials", AppController, :verify_credentials)
559 scope "/api/v1", Pleroma.Web.MastodonAPI do
562 get("/accounts/search", SearchController, :account_search)
563 get("/search", SearchController, :search)
565 get("/accounts/:id/statuses", AccountController, :statuses)
566 get("/accounts/:id/followers", AccountController, :followers)
567 get("/accounts/:id/following", AccountController, :following)
568 get("/accounts/:id", AccountController, :show)
570 post("/accounts", AccountController, :create)
572 get("/instance", InstanceController, :show)
573 get("/instance/peers", InstanceController, :peers)
575 get("/statuses", StatusController, :index)
576 get("/statuses/:id", StatusController, :show)
577 get("/statuses/:id/context", StatusController, :context)
578 get("/statuses/:id/card", StatusController, :card)
579 get("/statuses/:id/favourited_by", StatusController, :favourited_by)
580 get("/statuses/:id/reblogged_by", StatusController, :reblogged_by)
582 get("/custom_emojis", CustomEmojiController, :index)
584 get("/trends", MastodonAPIController, :empty_array)
586 get("/timelines/public", TimelineController, :public)
587 get("/timelines/tag/:tag", TimelineController, :hashtag)
589 get("/polls/:id", PollController, :show)
592 scope "/api/v2", Pleroma.Web.MastodonAPI do
594 get("/search", SearchController, :search2)
596 post("/media", MediaController, :create2)
599 scope "/api", Pleroma.Web do
600 pipe_through(:config)
602 get("/pleroma/frontend_configurations", TwitterAPI.UtilController, :frontend_configurations)
605 scope "/api", Pleroma.Web do
609 "/account/confirm_email/:user_id/:token",
610 TwitterAPI.Controller,
617 pipe_through(:base_api)
619 get("/openapi", OpenApiSpex.Plug.RenderSpec, [])
622 scope "/api", Pleroma.Web, as: :authenticated_twitter_api do
623 pipe_through(:authenticated_api)
625 get("/oauth_tokens", TwitterAPI.Controller, :oauth_tokens)
626 delete("/oauth_tokens/:id", TwitterAPI.Controller, :revoke_token)
629 "/qvitter/statuses/notifications/read",
630 TwitterAPI.Controller,
631 :mark_notifications_as_read
635 scope "/", Pleroma.Web do
636 # Note: html format is supported only if static FE is enabled
637 # Note: http signature is only considered for json requests (no auth for non-json requests)
638 pipe_through([:accepts_html_json, :http_signature, :static_fe])
640 get("/objects/:uuid", OStatus.OStatusController, :object)
641 get("/activities/:uuid", OStatus.OStatusController, :activity)
642 get("/notice/:id", OStatus.OStatusController, :notice)
644 # Mastodon compatibility routes
645 get("/users/:nickname/statuses/:id", OStatus.OStatusController, :object)
646 get("/users/:nickname/statuses/:id/activity", OStatus.OStatusController, :activity)
649 scope "/", Pleroma.Web do
650 # Note: html format is supported only if static FE is enabled
651 # Note: http signature is only considered for json requests (no auth for non-json requests)
652 pipe_through([:accepts_html_xml_json, :http_signature, :static_fe])
654 # Note: returns user _profile_ for json requests, redirects to user _feed_ for non-json ones
655 get("/users/:nickname", Feed.UserController, :feed_redirect, as: :user_feed)
658 scope "/", Pleroma.Web do
659 # Note: html format is supported only if static FE is enabled
660 pipe_through([:accepts_html_xml, :static_fe])
662 get("/users/:nickname/feed", Feed.UserController, :feed, as: :user_feed)
665 scope "/", Pleroma.Web do
666 pipe_through(:accepts_html)
667 get("/notice/:id/embed_player", OStatus.OStatusController, :notice_player)
670 scope "/", Pleroma.Web do
671 pipe_through(:accepts_xml_rss_atom)
672 get("/tags/:tag", Feed.TagController, :feed, as: :tag_feed)
675 scope "/", Pleroma.Web do
676 pipe_through(:browser)
677 get("/mailer/unsubscribe/:token", Mailer.SubscriptionController, :unsubscribe)
680 pipeline :ap_service_actor do
681 plug(:accepts, ["activity+json", "json"])
684 # Server to Server (S2S) AP interactions
685 pipeline :activitypub do
686 plug(:ap_service_actor)
687 plug(:http_signature)
690 # Client to Server (C2S) AP interactions
691 pipeline :activitypub_client do
692 plug(:ap_service_actor)
698 scope "/", Pleroma.Web.ActivityPub do
699 pipe_through([:activitypub_client])
701 get("/api/ap/whoami", ActivityPubController, :whoami)
702 get("/users/:nickname/inbox", ActivityPubController, :read_inbox)
704 get("/users/:nickname/outbox", ActivityPubController, :outbox)
705 post("/users/:nickname/outbox", ActivityPubController, :update_outbox)
706 post("/api/ap/upload_media", ActivityPubController, :upload_media)
708 # The following two are S2S as well, see `ActivityPub.fetch_follow_information_for_user/1`:
709 get("/users/:nickname/followers", ActivityPubController, :followers)
710 get("/users/:nickname/following", ActivityPubController, :following)
711 get("/users/:nickname/collections/featured", ActivityPubController, :pinned)
714 scope "/", Pleroma.Web.ActivityPub do
715 pipe_through(:activitypub)
716 post("/inbox", ActivityPubController, :inbox)
717 post("/users/:nickname/inbox", ActivityPubController, :inbox)
720 scope "/relay", Pleroma.Web.ActivityPub do
721 pipe_through(:ap_service_actor)
723 get("/", ActivityPubController, :relay)
726 pipe_through(:http_signature)
727 post("/inbox", ActivityPubController, :inbox)
730 get("/following", ActivityPubController, :relay_following)
731 get("/followers", ActivityPubController, :relay_followers)
734 scope "/internal/fetch", Pleroma.Web.ActivityPub do
735 pipe_through(:ap_service_actor)
737 get("/", ActivityPubController, :internal_fetch)
738 post("/inbox", ActivityPubController, :inbox)
741 scope "/.well-known", Pleroma.Web do
742 pipe_through(:well_known)
744 get("/host-meta", WebFinger.WebFingerController, :host_meta)
745 get("/webfinger", WebFinger.WebFingerController, :webfinger)
746 get("/nodeinfo", Nodeinfo.NodeinfoController, :schemas)
749 scope "/nodeinfo", Pleroma.Web do
750 get("/:version", Nodeinfo.NodeinfoController, :nodeinfo)
753 scope "/", Pleroma.Web do
756 get("/web/manifest.json", MastoFEController, :manifest)
759 scope "/", Pleroma.Web do
760 pipe_through(:mastodon_html)
762 get("/web/login", MastodonAPI.AuthController, :login)
763 delete("/auth/sign_out", MastodonAPI.AuthController, :logout)
765 post("/auth/password", MastodonAPI.AuthController, :password_reset)
767 get("/web/*path", MastoFEController, :index)
769 get("/embed/:id", EmbedController, :show)
772 scope "/proxy/", Pleroma.Web do
773 get("/preview/:sig/:url", MediaProxy.MediaProxyController, :preview)
774 get("/preview/:sig/:url/:filename", MediaProxy.MediaProxyController, :preview)
775 get("/:sig/:url", MediaProxy.MediaProxyController, :remote)
776 get("/:sig/:url/:filename", MediaProxy.MediaProxyController, :remote)
779 if Pleroma.Config.get(:env) == :dev do
781 pipe_through([:mailbox_preview])
783 forward("/mailbox", Plug.Swoosh.MailboxPreview, base_path: "/dev/mailbox")
787 # Test-only routes needed to test action dispatching and plug chain execution
788 if Pleroma.Config.get(:env) == :test do
791 :fallback_oauth_check,
793 :fallback_oauth_skip_publicity_check,
794 :skip_oauth_skip_publicity_check,
795 :missing_oauth_check_definition
798 scope "/test/api", Pleroma.Tests do
801 for action <- @test_actions do
802 get("/#{action}", AuthTestController, action)
806 scope "/test/authenticated_api", Pleroma.Tests do
807 pipe_through(:authenticated_api)
809 for action <- @test_actions do
810 get("/#{action}", AuthTestController, action)
815 scope "/", Pleroma.Web.MongooseIM do
816 get("/user_exists", MongooseIMController, :user_exists)
817 get("/check_password", MongooseIMController, :check_password)
820 scope "/", Pleroma.Web.Fallback do
821 get("/registration/:token", RedirectController, :registration_page)
822 get("/:maybe_nickname_or_id", RedirectController, :redirector_with_meta)
823 match(:*, "/api/pleroma*path", LegacyPleromaApiRerouterPlug, [])
824 get("/api*path", RedirectController, :api_not_implemented)
825 get("/*path", RedirectController, :redirector_with_preload)
827 options("/*path", RedirectController, :empty)
830 # TODO: Change to Phoenix.Router.routes/1 for Phoenix 1.6.0+
831 def get_api_routes do
832 __MODULE__.__routes__()
833 |> Enum.reject(fn r -> r.plug == Pleroma.Web.Fallback.RedirectController end)
836 |> String.split("/", trim: true)