1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.Router do
6 use Pleroma.Web, :router
7 import Phoenix.LiveDashboard.Router
9 pipeline :accepts_html do
10 plug(:accepts, ["html"])
13 pipeline :accepts_html_xml do
14 plug(:accepts, ["html", "xml", "rss", "atom"])
17 pipeline :accepts_html_json do
18 plug(:accepts, ["html", "activity+json", "json"])
21 pipeline :accepts_html_xml_json do
22 plug(:accepts, ["html", "xml", "rss", "atom", "activity+json", "json"])
25 pipeline :accepts_xml_rss_atom do
26 plug(:accepts, ["xml", "rss", "atom"])
30 plug(:accepts, ["html"])
36 plug(Pleroma.Web.Plugs.OAuthPlug)
37 plug(Pleroma.Web.Plugs.UserEnabledPlug)
38 plug(Pleroma.Web.Plugs.EnsureUserTokenAssignsPlug)
41 # Note: expects _user_ authentication (user-unbound app-bound tokens don't qualify)
42 pipeline :expect_user_authentication do
43 plug(Pleroma.Web.Plugs.ExpectAuthenticatedCheckPlug)
46 # Note: expects public instance or _user_ authentication (user-unbound tokens don't qualify)
47 pipeline :expect_public_instance_or_user_authentication do
48 plug(Pleroma.Web.Plugs.ExpectPublicOrAuthenticatedCheckPlug)
51 pipeline :authenticate do
52 plug(Pleroma.Web.Plugs.OAuthPlug)
53 plug(Pleroma.Web.Plugs.BasicAuthDecoderPlug)
54 plug(Pleroma.Web.Plugs.UserFetcherPlug)
55 plug(Pleroma.Web.Plugs.AuthenticationPlug)
58 pipeline :after_auth do
59 plug(Pleroma.Web.Plugs.UserEnabledPlug)
60 plug(Pleroma.Web.Plugs.SetUserSessionIdPlug)
61 plug(Pleroma.Web.Plugs.EnsureUserTokenAssignsPlug)
62 plug(Pleroma.Web.Plugs.UserTrackingPlug)
66 plug(:accepts, ["json"])
69 plug(OpenApiSpex.Plug.PutApiSpec, module: Pleroma.Web.ApiSpec)
72 pipeline :no_auth_or_privacy_expectations_api do
75 plug(Pleroma.Web.Plugs.IdempotencyPlug)
78 # Pipeline for app-related endpoints (no user auth checks — app-bound tokens must be supported)
80 plug(:no_auth_or_privacy_expectations_api)
84 plug(:expect_public_instance_or_user_authentication)
85 plug(:no_auth_or_privacy_expectations_api)
88 pipeline :authenticated_api do
89 plug(:expect_user_authentication)
90 plug(:no_auth_or_privacy_expectations_api)
91 plug(Pleroma.Web.Plugs.EnsureAuthenticatedPlug)
94 pipeline :admin_api do
95 plug(:expect_user_authentication)
97 plug(Pleroma.Web.Plugs.AdminSecretAuthenticationPlug)
99 plug(Pleroma.Web.Plugs.EnsureAuthenticatedPlug)
100 plug(Pleroma.Web.Plugs.UserIsStaffPlug)
101 plug(Pleroma.Web.Plugs.IdempotencyPlug)
104 pipeline :require_admin do
105 plug(Pleroma.Web.Plugs.UserIsAdminPlug)
108 pipeline :require_privileged_role_users_delete do
110 plug(Pleroma.Web.Plugs.EnsurePrivilegedPlug, :users_delete)
113 pipeline :require_privileged_role_users_manage_credentials do
115 plug(Pleroma.Web.Plugs.EnsurePrivilegedPlug, :users_manage_credentials)
118 pipeline :require_privileged_role_messages_read do
120 plug(Pleroma.Web.Plugs.EnsurePrivilegedPlug, :messages_read)
123 pipeline :require_privileged_role_users_manage_tags do
125 plug(Pleroma.Web.Plugs.EnsurePrivilegedPlug, :users_manage_tags)
128 pipeline :require_privileged_role_users_manage_activation_state do
130 plug(Pleroma.Web.Plugs.EnsurePrivilegedPlug, :users_manage_activation_state)
133 pipeline :require_privileged_role_users_manage_invites do
135 plug(Pleroma.Web.Plugs.EnsurePrivilegedPlug, :users_manage_invites)
138 pipeline :require_privileged_role_reports_manage_reports do
140 plug(Pleroma.Web.Plugs.EnsurePrivilegedPlug, :reports_manage_reports)
143 pipeline :require_privileged_role_users_read do
145 plug(Pleroma.Web.Plugs.EnsurePrivilegedPlug, :users_read)
148 pipeline :require_privileged_role_messages_delete do
150 plug(Pleroma.Web.Plugs.EnsurePrivilegedPlug, :messages_delete)
153 pipeline :require_privileged_role_emoji_manage_emoji do
155 plug(Pleroma.Web.Plugs.EnsurePrivilegedPlug, :emoji_manage_emoji)
158 pipeline :require_privileged_role_instances_delete do
160 plug(Pleroma.Web.Plugs.EnsurePrivilegedPlug, :instances_delete)
163 pipeline :require_privileged_role_moderation_log_read do
165 plug(Pleroma.Web.Plugs.EnsurePrivilegedPlug, :moderation_log_read)
168 pipeline :require_privileged_role_statistics_read do
170 plug(Pleroma.Web.Plugs.EnsurePrivilegedPlug, :statistics_read)
173 pipeline :require_privileged_role_announcements_manage_announcements do
175 plug(Pleroma.Web.Plugs.EnsurePrivilegedPlug, :announcements_manage_announcements)
178 pipeline :pleroma_html do
181 plug(Pleroma.Web.Plugs.EnsureUserTokenAssignsPlug)
184 pipeline :well_known do
185 plug(:accepts, ["json", "jrd+json", "xml", "xrd+xml"])
189 plug(:accepts, ["json", "xml"])
190 plug(OpenApiSpex.Plug.PutApiSpec, module: Pleroma.Web.ApiSpec)
193 pipeline :pleroma_api do
194 plug(:accepts, ["html", "json"])
195 plug(OpenApiSpex.Plug.PutApiSpec, module: Pleroma.Web.ApiSpec)
198 pipeline :mailbox_preview do
199 plug(:accepts, ["html"])
201 plug(:put_secure_browser_headers, %{
202 "content-security-policy" =>
203 "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline' 'unsafe-eval'"
207 pipeline :http_signature do
208 plug(Pleroma.Web.Plugs.HTTPSignaturePlug)
209 plug(Pleroma.Web.Plugs.MappedSignatureToIdentityPlug)
212 pipeline :static_fe do
213 plug(Pleroma.Web.Plugs.StaticFEPlug)
216 scope "/api/v1/pleroma", Pleroma.Web.TwitterAPI do
217 pipe_through(:pleroma_api)
219 get("/password_reset/:token", PasswordController, :reset, as: :reset_password)
220 post("/password_reset", PasswordController, :do_reset, as: :reset_password)
221 get("/emoji", UtilController, :emoji)
222 get("/captcha", UtilController, :captcha)
223 get("/healthcheck", UtilController, :healthcheck)
224 post("/remote_interaction", UtilController, :remote_interaction)
227 scope "/api/v1/pleroma", Pleroma.Web do
228 pipe_through(:pleroma_api)
229 post("/uploader_callback/:upload_path", UploaderController, :callback)
232 scope "/api/v1/pleroma/emoji", Pleroma.Web.PleromaAPI do
234 pipe_through(:require_privileged_role_emoji_manage_emoji)
236 post("/", EmojiPackController, :create)
237 patch("/", EmojiPackController, :update)
238 delete("/", EmojiPackController, :delete)
244 get("/", EmojiPackController, :show)
249 pipe_through(:require_privileged_role_emoji_manage_emoji)
251 get("/import", EmojiPackController, :import_from_filesystem)
252 get("/remote", EmojiPackController, :remote)
253 post("/download", EmojiPackController, :download)
255 post("/files", EmojiFileController, :create)
256 patch("/files", EmojiFileController, :update)
257 delete("/files", EmojiFileController, :delete)
260 # Pack info / downloading
264 get("/", EmojiPackController, :index)
265 get("/archive", EmojiPackController, :archive)
269 scope "/", Pleroma.Web.TwitterAPI do
270 pipe_through(:pleroma_html)
272 post("/main/ostatus", UtilController, :remote_subscribe)
273 get("/main/ostatus", UtilController, :show_subscribe_form)
274 get("/ostatus_subscribe", RemoteFollowController, :follow)
275 post("/ostatus_subscribe", RemoteFollowController, :do_follow)
278 scope "/api/pleroma", Pleroma.Web.TwitterAPI do
279 pipe_through(:authenticated_api)
281 post("/change_email", UtilController, :change_email)
282 post("/change_password", UtilController, :change_password)
283 post("/delete_account", UtilController, :delete_account)
284 put("/notification_settings", UtilController, :update_notificaton_settings)
285 post("/disable_account", UtilController, :disable_account)
286 post("/move_account", UtilController, :move_account)
288 put("/aliases", UtilController, :add_alias)
289 get("/aliases", UtilController, :list_aliases)
290 delete("/aliases", UtilController, :delete_alias)
293 scope "/api/pleroma", Pleroma.Web.PleromaAPI do
294 pipe_through(:authenticated_api)
296 post("/mutes_import", UserImportController, :mutes)
297 post("/blocks_import", UserImportController, :blocks)
298 post("/follow_import", UserImportController, :follow)
300 get("/accounts/mfa", TwoFactorAuthenticationController, :settings)
301 get("/accounts/mfa/backup_codes", TwoFactorAuthenticationController, :backup_codes)
302 get("/accounts/mfa/setup/:method", TwoFactorAuthenticationController, :setup)
303 post("/accounts/mfa/confirm/:method", TwoFactorAuthenticationController, :confirm)
304 delete("/accounts/mfa/:method", TwoFactorAuthenticationController, :disable)
307 scope "/oauth", Pleroma.Web.OAuth do
308 # Note: use /api/v1/accounts/verify_credentials for userinfo of signed-in user
310 get("/registration_details", OAuthController, :registration_details)
312 post("/mfa/verify", MFAController, :verify, as: :mfa_verify)
313 get("/mfa", MFAController, :show)
318 get("/authorize", OAuthController, :authorize)
319 post("/authorize", OAuthController, :create_authorization)
323 pipe_through(:fetch_session)
325 post("/token", OAuthController, :token_exchange)
326 post("/revoke", OAuthController, :token_revoke)
327 post("/mfa/challenge", MFAController, :challenge)
331 pipe_through(:browser)
333 get("/prepare_request", OAuthController, :prepare_request)
334 get("/:provider", OAuthController, :request)
335 get("/:provider/callback", OAuthController, :callback)
336 post("/register", OAuthController, :register)
340 scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do
343 get("/apps", AppController, :index)
344 get("/statuses/:id/reactions/:emoji", EmojiReactionController, :index)
345 get("/statuses/:id/reactions", EmojiReactionController, :index)
348 scope "/api/v0/pleroma", Pleroma.Web.PleromaAPI do
349 pipe_through(:authenticated_api)
350 get("/reports", ReportController, :index)
351 get("/reports/:id", ReportController, :show)
354 scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do
356 pipe_through(:authenticated_api)
358 post("/chats/by-account-id/:id", ChatController, :create)
359 get("/chats", ChatController, :index)
360 get("/chats/:id", ChatController, :show)
361 get("/chats/:id/messages", ChatController, :messages)
362 post("/chats/:id/messages", ChatController, :post_chat_message)
363 delete("/chats/:id/messages/:message_id", ChatController, :delete_message)
364 post("/chats/:id/read", ChatController, :mark_as_read)
365 post("/chats/:id/messages/:message_id/read", ChatController, :mark_message_as_read)
367 get("/conversations/:id/statuses", ConversationController, :statuses)
368 get("/conversations/:id", ConversationController, :show)
369 post("/conversations/read", ConversationController, :mark_as_read)
370 patch("/conversations/:id", ConversationController, :update)
372 put("/statuses/:id/reactions/:emoji", EmojiReactionController, :create)
373 delete("/statuses/:id/reactions/:emoji", EmojiReactionController, :delete)
374 post("/notifications/read", NotificationController, :mark_as_read)
376 get("/mascot", MascotController, :show)
377 put("/mascot", MascotController, :update)
379 post("/scrobble", ScrobbleController, :create)
381 get("/backups", BackupController, :index)
382 post("/backups", BackupController, :create)
387 get("/accounts/:id/favourites", AccountController, :favourites)
388 get("/accounts/:id/endorsements", AccountController, :endorsements)
392 pipe_through(:authenticated_api)
394 post("/accounts/:id/subscribe", AccountController, :subscribe)
395 post("/accounts/:id/unsubscribe", AccountController, :unsubscribe)
397 get("/birthdays", AccountController, :birthdays)
401 pipe_through(:authenticated_api)
403 get("/settings/:app", SettingsController, :show)
404 patch("/settings/:app", SettingsController, :update)
407 post("/accounts/confirmation_resend", AccountController, :confirmation_resend)
410 scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do
412 get("/accounts/:id/scrobbles", ScrobbleController, :index)
413 get("/federation_status", InstancesController, :show)
416 scope "/api/v2/pleroma", Pleroma.Web.PleromaAPI do
418 pipe_through(:authenticated_api)
419 get("/chats", ChatController, :index2)
423 scope "/api/v1", Pleroma.Web.MastodonAPI do
424 pipe_through(:authenticated_api)
426 get("/accounts/verify_credentials", AccountController, :verify_credentials)
427 patch("/accounts/update_credentials", AccountController, :update_credentials)
429 get("/accounts/relationships", AccountController, :relationships)
430 get("/accounts/:id/lists", AccountController, :lists)
431 get("/accounts/:id/identity_proofs", AccountController, :identity_proofs)
432 get("/endorsements", AccountController, :endorsements)
433 get("/blocks", AccountController, :blocks)
434 get("/mutes", AccountController, :mutes)
436 post("/follows", AccountController, :follow_by_uri)
437 post("/accounts/:id/follow", AccountController, :follow)
438 post("/accounts/:id/unfollow", AccountController, :unfollow)
439 post("/accounts/:id/block", AccountController, :block)
440 post("/accounts/:id/unblock", AccountController, :unblock)
441 post("/accounts/:id/mute", AccountController, :mute)
442 post("/accounts/:id/unmute", AccountController, :unmute)
443 post("/accounts/:id/note", AccountController, :note)
444 post("/accounts/:id/pin", AccountController, :endorse)
445 post("/accounts/:id/unpin", AccountController, :unendorse)
446 post("/accounts/:id/remove_from_followers", AccountController, :remove_from_followers)
448 get("/conversations", ConversationController, :index)
449 post("/conversations/:id/read", ConversationController, :mark_as_read)
450 delete("/conversations/:id", ConversationController, :delete)
452 get("/domain_blocks", DomainBlockController, :index)
453 post("/domain_blocks", DomainBlockController, :create)
454 delete("/domain_blocks", DomainBlockController, :delete)
456 get("/filters", FilterController, :index)
458 post("/filters", FilterController, :create)
459 get("/filters/:id", FilterController, :show)
460 put("/filters/:id", FilterController, :update)
461 delete("/filters/:id", FilterController, :delete)
463 get("/follow_requests", FollowRequestController, :index)
464 post("/follow_requests/:id/authorize", FollowRequestController, :authorize)
465 post("/follow_requests/:id/reject", FollowRequestController, :reject)
467 get("/lists", ListController, :index)
468 get("/lists/:id", ListController, :show)
469 get("/lists/:id/accounts", ListController, :list_accounts)
471 delete("/lists/:id", ListController, :delete)
472 post("/lists", ListController, :create)
473 put("/lists/:id", ListController, :update)
474 post("/lists/:id/accounts", ListController, :add_to_list)
475 delete("/lists/:id/accounts", ListController, :remove_from_list)
477 get("/markers", MarkerController, :index)
478 post("/markers", MarkerController, :upsert)
480 post("/media", MediaController, :create)
481 get("/media/:id", MediaController, :show)
482 put("/media/:id", MediaController, :update)
484 get("/notifications", NotificationController, :index)
485 get("/notifications/:id", NotificationController, :show)
487 post("/notifications/:id/dismiss", NotificationController, :dismiss)
488 post("/notifications/clear", NotificationController, :clear)
489 delete("/notifications/destroy_multiple", NotificationController, :destroy_multiple)
490 # Deprecated: was removed in Mastodon v3, use `/notifications/:id/dismiss` instead
491 post("/notifications/dismiss", NotificationController, :dismiss_via_body)
493 post("/polls/:id/votes", PollController, :vote)
495 post("/reports", ReportController, :create)
497 get("/scheduled_statuses", ScheduledActivityController, :index)
498 get("/scheduled_statuses/:id", ScheduledActivityController, :show)
500 put("/scheduled_statuses/:id", ScheduledActivityController, :update)
501 delete("/scheduled_statuses/:id", ScheduledActivityController, :delete)
503 # Unlike `GET /api/v1/accounts/:id/favourites`, demands authentication
504 get("/favourites", StatusController, :favourites)
505 get("/bookmarks", StatusController, :bookmarks)
507 post("/statuses", StatusController, :create)
508 put("/statuses/:id", StatusController, :update)
509 delete("/statuses/:id", StatusController, :delete)
510 post("/statuses/:id/reblog", StatusController, :reblog)
511 post("/statuses/:id/unreblog", StatusController, :unreblog)
512 post("/statuses/:id/favourite", StatusController, :favourite)
513 post("/statuses/:id/unfavourite", StatusController, :unfavourite)
514 post("/statuses/:id/pin", StatusController, :pin)
515 post("/statuses/:id/unpin", StatusController, :unpin)
516 post("/statuses/:id/bookmark", StatusController, :bookmark)
517 post("/statuses/:id/unbookmark", StatusController, :unbookmark)
518 post("/statuses/:id/mute", StatusController, :mute_conversation)
519 post("/statuses/:id/unmute", StatusController, :unmute_conversation)
521 post("/push/subscription", SubscriptionController, :create)
522 get("/push/subscription", SubscriptionController, :show)
523 put("/push/subscription", SubscriptionController, :update)
524 delete("/push/subscription", SubscriptionController, :delete)
526 get("/suggestions", SuggestionController, :index)
527 delete("/suggestions/:account_id", SuggestionController, :dismiss)
529 get("/timelines/home", TimelineController, :home)
530 get("/timelines/direct", TimelineController, :direct)
531 get("/timelines/list/:list_id", TimelineController, :list)
533 get("/announcements", AnnouncementController, :index)
534 post("/announcements/:id/dismiss", AnnouncementController, :mark_read)
537 scope "/api/v1", Pleroma.Web.MastodonAPI do
538 pipe_through(:app_api)
540 post("/apps", AppController, :create)
541 get("/apps/verify_credentials", AppController, :verify_credentials)
544 scope "/api/v1", Pleroma.Web.MastodonAPI do
547 get("/accounts/search", SearchController, :account_search)
548 get("/search", SearchController, :search)
550 get("/accounts/lookup", AccountController, :lookup)
552 get("/accounts/:id/statuses", AccountController, :statuses)
553 get("/accounts/:id/followers", AccountController, :followers)
554 get("/accounts/:id/following", AccountController, :following)
555 get("/accounts/:id", AccountController, :show)
557 post("/accounts", AccountController, :create)
559 get("/instance", InstanceController, :show)
560 get("/instance/peers", InstanceController, :peers)
562 get("/statuses", StatusController, :index)
563 get("/statuses/:id", StatusController, :show)
564 get("/statuses/:id/context", StatusController, :context)
565 get("/statuses/:id/card", StatusController, :card)
566 get("/statuses/:id/favourited_by", StatusController, :favourited_by)
567 get("/statuses/:id/reblogged_by", StatusController, :reblogged_by)
568 get("/statuses/:id/history", StatusController, :show_history)
569 get("/statuses/:id/source", StatusController, :show_source)
571 get("/custom_emojis", CustomEmojiController, :index)
573 get("/trends", MastodonAPIController, :empty_array)
575 get("/timelines/public", TimelineController, :public)
576 get("/timelines/tag/:tag", TimelineController, :hashtag)
578 get("/polls/:id", PollController, :show)
580 get("/directory", DirectoryController, :index)
583 scope "/api/v2", Pleroma.Web.MastodonAPI do
585 get("/search", SearchController, :search2)
587 post("/media", MediaController, :create2)
589 get("/suggestions", SuggestionController, :index2)
592 scope "/api", Pleroma.Web do
593 pipe_through(:config)
595 get("/pleroma/frontend_configurations", TwitterAPI.UtilController, :frontend_configurations)
598 scope "/api", Pleroma.Web do
602 "/account/confirm_email/:user_id/:token",
603 TwitterAPI.Controller,
610 pipe_through(:base_api)
612 get("/openapi", OpenApiSpex.Plug.RenderSpec, [])
615 scope "/api", Pleroma.Web, as: :authenticated_twitter_api do
616 pipe_through(:authenticated_api)
618 get("/oauth_tokens", TwitterAPI.Controller, :oauth_tokens)
619 delete("/oauth_tokens/:id", TwitterAPI.Controller, :revoke_token)
622 scope "/", Pleroma.Web do
623 # Note: html format is supported only if static FE is enabled
624 # Note: http signature is only considered for json requests (no auth for non-json requests)
625 pipe_through([:accepts_html_json, :http_signature, :static_fe])
627 get("/objects/:uuid", OStatus.OStatusController, :object)
628 get("/activities/:uuid", OStatus.OStatusController, :activity)
629 get("/notice/:id", OStatus.OStatusController, :notice)
631 # Mastodon compatibility routes
632 get("/users/:nickname/statuses/:id", OStatus.OStatusController, :object)
633 get("/users/:nickname/statuses/:id/activity", OStatus.OStatusController, :activity)
636 scope "/", Pleroma.Web do
637 # Note: html format is supported only if static FE is enabled
638 # Note: http signature is only considered for json requests (no auth for non-json requests)
639 pipe_through([:accepts_html_xml_json, :http_signature, :static_fe])
641 # Note: returns user _profile_ for json requests, redirects to user _feed_ for non-json ones
642 get("/users/:nickname", Feed.UserController, :feed_redirect, as: :user_feed)
645 scope "/", Pleroma.Web do
646 pipe_through([:accepts_html_xml])
648 get("/users/:nickname/feed", Feed.UserController, :feed, as: :user_feed)
651 scope "/", Pleroma.Web do
652 pipe_through(:accepts_html)
653 get("/notice/:id/embed_player", OStatus.OStatusController, :notice_player)
656 scope "/", Pleroma.Web do
657 pipe_through(:accepts_xml_rss_atom)
658 get("/tags/:tag", Feed.TagController, :feed, as: :tag_feed)
661 scope "/", Pleroma.Web do
662 pipe_through(:browser)
663 get("/mailer/unsubscribe/:token", Mailer.SubscriptionController, :unsubscribe)
666 pipeline :ap_service_actor do
667 plug(:accepts, ["activity+json", "json"])
670 # Server to Server (S2S) AP interactions
671 pipeline :activitypub do
672 plug(:ap_service_actor)
673 plug(:http_signature)
676 # Client to Server (C2S) AP interactions
677 pipeline :activitypub_client do
678 plug(:ap_service_actor)
684 scope "/", Pleroma.Web.ActivityPub do
685 pipe_through([:activitypub_client])
687 get("/api/ap/whoami", ActivityPubController, :whoami)
688 get("/users/:nickname/inbox", ActivityPubController, :read_inbox)
690 get("/users/:nickname/outbox", ActivityPubController, :outbox)
691 post("/users/:nickname/outbox", ActivityPubController, :update_outbox)
692 post("/api/ap/upload_media", ActivityPubController, :upload_media)
694 # The following two are S2S as well, see `ActivityPub.fetch_follow_information_for_user/1`:
695 get("/users/:nickname/followers", ActivityPubController, :followers)
696 get("/users/:nickname/following", ActivityPubController, :following)
697 get("/users/:nickname/collections/featured", ActivityPubController, :pinned)
700 scope "/", Pleroma.Web.ActivityPub do
701 pipe_through(:activitypub)
702 post("/inbox", ActivityPubController, :inbox)
703 post("/users/:nickname/inbox", ActivityPubController, :inbox)
706 scope "/relay", Pleroma.Web.ActivityPub do
707 pipe_through(:ap_service_actor)
709 get("/", ActivityPubController, :relay)
712 pipe_through(:http_signature)
713 post("/inbox", ActivityPubController, :inbox)
716 get("/following", ActivityPubController, :relay_following)
717 get("/followers", ActivityPubController, :relay_followers)
720 scope "/internal/fetch", Pleroma.Web.ActivityPub do
721 pipe_through(:ap_service_actor)
723 get("/", ActivityPubController, :internal_fetch)
724 post("/inbox", ActivityPubController, :inbox)
727 scope "/.well-known", Pleroma.Web do
728 pipe_through(:well_known)
730 get("/host-meta", WebFinger.WebFingerController, :host_meta)
731 get("/webfinger", WebFinger.WebFingerController, :webfinger)
732 get("/nodeinfo", Nodeinfo.NodeinfoController, :schemas)
735 scope "/nodeinfo", Pleroma.Web do
736 get("/:version", Nodeinfo.NodeinfoController, :nodeinfo)
739 scope "/", Pleroma.Web do
742 get("/manifest.json", ManifestController, :show)
745 scope "/", Pleroma.Web do
746 pipe_through(:pleroma_html)
748 post("/auth/password", TwitterAPI.PasswordController, :request)
751 scope "/proxy/", Pleroma.Web do
752 get("/preview/:sig/:url", MediaProxy.MediaProxyController, :preview)
753 get("/preview/:sig/:url/:filename", MediaProxy.MediaProxyController, :preview)
754 get("/:sig/:url", MediaProxy.MediaProxyController, :remote)
755 get("/:sig/:url/:filename", MediaProxy.MediaProxyController, :remote)
758 if Pleroma.Config.get(:env) == :dev do
760 pipe_through([:mailbox_preview])
762 forward("/mailbox", Plug.Swoosh.MailboxPreview, base_path: "/dev/mailbox")
767 pipe_through([:pleroma_html, :authenticate, :require_admin])
768 live_dashboard("/phoenix/live_dashboard")
771 # Test-only routes needed to test action dispatching and plug chain execution
772 if Pleroma.Config.get(:env) == :test do
775 :fallback_oauth_check,
777 :fallback_oauth_skip_publicity_check,
778 :skip_oauth_skip_publicity_check,
779 :missing_oauth_check_definition
782 scope "/test/api", Pleroma.Tests do
785 for action <- @test_actions do
786 get("/#{action}", AuthTestController, action)
790 scope "/test/authenticated_api", Pleroma.Tests do
791 pipe_through(:authenticated_api)
793 for action <- @test_actions do
794 get("/#{action}", AuthTestController, action)
799 scope "/", Pleroma.Web.MongooseIM do
800 get("/user_exists", MongooseIMController, :user_exists)
801 get("/check_password", MongooseIMController, :check_password)
804 scope "/", Pleroma.Web.Fallback do
805 get("/registration/:token", RedirectController, :registration_page)
806 get("/:maybe_nickname_or_id", RedirectController, :redirector_with_meta)
807 match(:*, "/api/pleroma*path", LegacyPleromaApiRerouterPlug, [])
808 get("/api*path", RedirectController, :api_not_implemented)
809 get("/*path", RedirectController, :redirector_with_preload)
811 options("/*path", RedirectController, :empty)
814 # TODO: Change to Phoenix.Router.routes/1 for Phoenix 1.6.0+
815 def get_api_routes do
816 __MODULE__.__routes__()
817 |> Enum.reject(fn r -> r.plug == Pleroma.Web.Fallback.RedirectController end)
820 |> String.split("/", trim: true)