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
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_privileged_staff do
105 plug(Pleroma.Web.Plugs.EnsureStaffPrivilegedPlug)
108 pipeline :require_admin do
109 plug(Pleroma.Web.Plugs.UserIsAdminPlug)
112 pipeline :pleroma_html do
115 plug(Pleroma.Web.Plugs.EnsureUserTokenAssignsPlug)
118 pipeline :well_known do
119 plug(:accepts, ["json", "jrd+json", "xml", "xrd+xml"])
123 plug(:accepts, ["json", "xml"])
124 plug(OpenApiSpex.Plug.PutApiSpec, module: Pleroma.Web.ApiSpec)
127 pipeline :pleroma_api do
128 plug(:accepts, ["html", "json"])
129 plug(OpenApiSpex.Plug.PutApiSpec, module: Pleroma.Web.ApiSpec)
132 pipeline :mailbox_preview do
133 plug(:accepts, ["html"])
135 plug(:put_secure_browser_headers, %{
136 "content-security-policy" =>
137 "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline' 'unsafe-eval'"
141 pipeline :http_signature do
142 plug(Pleroma.Web.Plugs.HTTPSignaturePlug)
143 plug(Pleroma.Web.Plugs.MappedSignatureToIdentityPlug)
146 pipeline :static_fe do
147 plug(Pleroma.Web.Plugs.StaticFEPlug)
150 scope "/api/v1/pleroma", Pleroma.Web.TwitterAPI do
151 pipe_through(:pleroma_api)
153 get("/password_reset/:token", PasswordController, :reset, as: :reset_password)
154 post("/password_reset", PasswordController, :do_reset, as: :reset_password)
155 get("/emoji", UtilController, :emoji)
156 get("/captcha", UtilController, :captcha)
157 get("/healthcheck", UtilController, :healthcheck)
158 post("/remote_interaction", UtilController, :remote_interaction)
161 scope "/api/v1/pleroma", Pleroma.Web do
162 pipe_through(:pleroma_api)
163 post("/uploader_callback/:upload_path", UploaderController, :callback)
166 # AdminAPI: only admins can perform these actions
167 scope "/api/v1/pleroma/admin", Pleroma.Web.AdminAPI do
168 pipe_through([:admin_api, :require_admin])
170 put("/users/disable_mfa", AdminAPIController, :disable_mfa)
172 get("/users/:nickname/permission_group", AdminAPIController, :right_get)
173 get("/users/:nickname/permission_group/:permission_group", AdminAPIController, :right_get)
175 post("/users/:nickname/permission_group/:permission_group", AdminAPIController, :right_add)
178 "/users/:nickname/permission_group/:permission_group",
183 post("/users/permission_group/:permission_group", AdminAPIController, :right_add_multiple)
186 "/users/permission_group/:permission_group",
188 :right_delete_multiple
191 post("/users/follow", UserController, :follow)
192 post("/users/unfollow", UserController, :unfollow)
193 post("/users", UserController, :create)
195 patch("/users/suggest", UserController, :suggest)
196 patch("/users/unsuggest", UserController, :unsuggest)
198 get("/relay", RelayController, :index)
199 post("/relay", RelayController, :follow)
200 delete("/relay", RelayController, :unfollow)
202 patch("/users/force_password_reset", AdminAPIController, :force_password_reset)
203 get("/users/:nickname/credentials", AdminAPIController, :show_user_credentials)
204 patch("/users/:nickname/credentials", AdminAPIController, :update_user_credentials)
206 get("/instance_document/:name", InstanceDocumentController, :show)
207 patch("/instance_document/:name", InstanceDocumentController, :update)
208 delete("/instance_document/:name", InstanceDocumentController, :delete)
210 patch("/users/confirm_email", AdminAPIController, :confirm_email)
211 patch("/users/resend_confirmation_email", AdminAPIController, :resend_confirmation_email)
213 get("/config", ConfigController, :show)
214 post("/config", ConfigController, :update)
215 get("/config/descriptions", ConfigController, :descriptions)
216 get("/need_reboot", AdminAPIController, :need_reboot)
217 get("/restart", AdminAPIController, :restart)
219 get("/oauth_app", OAuthAppController, :index)
220 post("/oauth_app", OAuthAppController, :create)
221 patch("/oauth_app/:id", OAuthAppController, :update)
222 delete("/oauth_app/:id", OAuthAppController, :delete)
224 get("/media_proxy_caches", MediaProxyCacheController, :index)
225 post("/media_proxy_caches/delete", MediaProxyCacheController, :delete)
226 post("/media_proxy_caches/purge", MediaProxyCacheController, :purge)
228 get("/frontends", FrontendController, :index)
229 post("/frontends/install", FrontendController, :install)
231 post("/backups", AdminAPIController, :create_backup)
234 # AdminAPI: admins and mods (staff) can perform these actions (if enabled by config)
235 scope "/api/v1/pleroma/admin", Pleroma.Web.AdminAPI do
236 pipe_through([:admin_api, :require_privileged_staff])
238 delete("/users", UserController, :delete)
240 get("/users/:nickname/password_reset", AdminAPIController, :get_password_reset)
241 patch("/users/:nickname/credentials", AdminAPIController, :update_user_credentials)
243 get("/users/:nickname/statuses", AdminAPIController, :list_user_statuses)
244 get("/users/:nickname/chats", AdminAPIController, :list_user_chats)
246 get("/statuses", StatusController, :index)
248 get("/chats/:id", ChatController, :show)
249 get("/chats/:id/messages", ChatController, :messages)
252 # AdminAPI: admins and mods (staff) can perform these actions
253 scope "/api/v1/pleroma/admin", Pleroma.Web.AdminAPI do
254 pipe_through(:admin_api)
256 put("/users/tag", AdminAPIController, :tag_users)
257 delete("/users/tag", AdminAPIController, :untag_users)
259 patch("/users/:nickname/toggle_activation", UserController, :toggle_activation)
260 patch("/users/activate", UserController, :activate)
261 patch("/users/deactivate", UserController, :deactivate)
262 patch("/users/approve", UserController, :approve)
264 post("/users/invite_token", InviteController, :create)
265 get("/users/invites", InviteController, :index)
266 post("/users/revoke_invite", InviteController, :revoke)
267 post("/users/email_invite", InviteController, :email)
269 get("/users", UserController, :index)
270 get("/users/:nickname", UserController, :show)
272 get("/instances/:instance/statuses", InstanceController, :list_statuses)
273 delete("/instances/:instance", InstanceController, :delete)
275 get("/reports", ReportController, :index)
276 get("/reports/:id", ReportController, :show)
277 patch("/reports", ReportController, :update)
278 post("/reports/:id/notes", ReportController, :notes_create)
279 delete("/reports/:report_id/notes/:id", ReportController, :notes_delete)
281 get("/statuses/:id", StatusController, :show)
282 put("/statuses/:id", StatusController, :update)
283 delete("/statuses/:id", StatusController, :delete)
285 get("/moderation_log", AdminAPIController, :list_log)
287 post("/reload_emoji", AdminAPIController, :reload_emoji)
288 get("/stats", AdminAPIController, :stats)
290 delete("/chats/:id/messages/:message_id", ChatController, :delete_message)
293 scope "/api/v1/pleroma/emoji", Pleroma.Web.PleromaAPI do
295 pipe_through(:admin_api)
297 post("/", EmojiPackController, :create)
298 patch("/", EmojiPackController, :update)
299 delete("/", EmojiPackController, :delete)
305 get("/", EmojiPackController, :show)
310 pipe_through(:admin_api)
312 get("/import", EmojiPackController, :import_from_filesystem)
313 get("/remote", EmojiPackController, :remote)
314 post("/download", EmojiPackController, :download)
316 post("/files", EmojiFileController, :create)
317 patch("/files", EmojiFileController, :update)
318 delete("/files", EmojiFileController, :delete)
321 # Pack info / downloading
325 get("/", EmojiPackController, :index)
326 get("/archive", EmojiPackController, :archive)
330 scope "/", Pleroma.Web.TwitterAPI do
331 pipe_through(:pleroma_html)
333 post("/main/ostatus", UtilController, :remote_subscribe)
334 get("/ostatus_subscribe", RemoteFollowController, :follow)
335 post("/ostatus_subscribe", RemoteFollowController, :do_follow)
338 scope "/api/pleroma", Pleroma.Web.TwitterAPI do
339 pipe_through(:authenticated_api)
341 post("/change_email", UtilController, :change_email)
342 post("/change_password", UtilController, :change_password)
343 post("/delete_account", UtilController, :delete_account)
344 put("/notification_settings", UtilController, :update_notificaton_settings)
345 post("/disable_account", UtilController, :disable_account)
348 scope "/api/pleroma", Pleroma.Web.PleromaAPI do
349 pipe_through(:authenticated_api)
351 post("/mutes_import", UserImportController, :mutes)
352 post("/blocks_import", UserImportController, :blocks)
353 post("/follow_import", UserImportController, :follow)
355 get("/accounts/mfa", TwoFactorAuthenticationController, :settings)
356 get("/accounts/mfa/backup_codes", TwoFactorAuthenticationController, :backup_codes)
357 get("/accounts/mfa/setup/:method", TwoFactorAuthenticationController, :setup)
358 post("/accounts/mfa/confirm/:method", TwoFactorAuthenticationController, :confirm)
359 delete("/accounts/mfa/:method", TwoFactorAuthenticationController, :disable)
362 scope "/oauth", Pleroma.Web.OAuth do
363 # Note: use /api/v1/accounts/verify_credentials for userinfo of signed-in user
365 get("/registration_details", OAuthController, :registration_details)
367 post("/mfa/verify", MFAController, :verify, as: :mfa_verify)
368 get("/mfa", MFAController, :show)
373 get("/authorize", OAuthController, :authorize)
374 post("/authorize", OAuthController, :create_authorization)
378 pipe_through(:fetch_session)
380 post("/token", OAuthController, :token_exchange)
381 post("/revoke", OAuthController, :token_revoke)
382 post("/mfa/challenge", MFAController, :challenge)
386 pipe_through(:browser)
388 get("/prepare_request", OAuthController, :prepare_request)
389 get("/:provider", OAuthController, :request)
390 get("/:provider/callback", OAuthController, :callback)
391 post("/register", OAuthController, :register)
395 scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do
398 get("/apps", AppController, :index)
399 get("/statuses/:id/reactions/:emoji", EmojiReactionController, :index)
400 get("/statuses/:id/reactions", EmojiReactionController, :index)
403 scope "/api/v0/pleroma", Pleroma.Web.PleromaAPI do
404 pipe_through(:authenticated_api)
405 get("/reports", ReportController, :index)
406 get("/reports/:id", ReportController, :show)
409 scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do
411 pipe_through(:authenticated_api)
413 post("/chats/by-account-id/:id", ChatController, :create)
414 get("/chats", ChatController, :index)
415 get("/chats/:id", ChatController, :show)
416 get("/chats/:id/messages", ChatController, :messages)
417 post("/chats/:id/messages", ChatController, :post_chat_message)
418 delete("/chats/:id/messages/:message_id", ChatController, :delete_message)
419 post("/chats/:id/read", ChatController, :mark_as_read)
420 post("/chats/:id/messages/:message_id/read", ChatController, :mark_message_as_read)
422 get("/conversations/:id/statuses", ConversationController, :statuses)
423 get("/conversations/:id", ConversationController, :show)
424 post("/conversations/read", ConversationController, :mark_as_read)
425 patch("/conversations/:id", ConversationController, :update)
427 put("/statuses/:id/reactions/:emoji", EmojiReactionController, :create)
428 delete("/statuses/:id/reactions/:emoji", EmojiReactionController, :delete)
429 post("/notifications/read", NotificationController, :mark_as_read)
431 get("/mascot", MascotController, :show)
432 put("/mascot", MascotController, :update)
434 post("/scrobble", ScrobbleController, :create)
436 get("/backups", BackupController, :index)
437 post("/backups", BackupController, :create)
442 get("/accounts/:id/favourites", AccountController, :favourites)
446 pipe_through(:authenticated_api)
448 post("/accounts/:id/subscribe", AccountController, :subscribe)
449 post("/accounts/:id/unsubscribe", AccountController, :unsubscribe)
452 post("/accounts/confirmation_resend", AccountController, :confirmation_resend)
455 scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do
457 get("/accounts/:id/scrobbles", ScrobbleController, :index)
458 get("/federation_status", InstancesController, :show)
461 scope "/api/v2/pleroma", Pleroma.Web.PleromaAPI do
463 pipe_through(:authenticated_api)
464 get("/chats", ChatController, :index2)
468 scope "/api/v1", Pleroma.Web.MastodonAPI do
469 pipe_through(:authenticated_api)
471 get("/accounts/verify_credentials", AccountController, :verify_credentials)
472 patch("/accounts/update_credentials", AccountController, :update_credentials)
474 get("/accounts/relationships", AccountController, :relationships)
475 get("/accounts/:id/lists", AccountController, :lists)
476 get("/accounts/:id/identity_proofs", AccountController, :identity_proofs)
477 get("/endorsements", AccountController, :endorsements)
478 get("/blocks", AccountController, :blocks)
479 get("/mutes", AccountController, :mutes)
481 post("/follows", AccountController, :follow_by_uri)
482 post("/accounts/:id/follow", AccountController, :follow)
483 post("/accounts/:id/unfollow", AccountController, :unfollow)
484 post("/accounts/:id/block", AccountController, :block)
485 post("/accounts/:id/unblock", AccountController, :unblock)
486 post("/accounts/:id/mute", AccountController, :mute)
487 post("/accounts/:id/unmute", AccountController, :unmute)
488 post("/accounts/:id/note", AccountController, :note)
490 get("/conversations", ConversationController, :index)
491 post("/conversations/:id/read", ConversationController, :mark_as_read)
492 delete("/conversations/:id", ConversationController, :delete)
494 get("/domain_blocks", DomainBlockController, :index)
495 post("/domain_blocks", DomainBlockController, :create)
496 delete("/domain_blocks", DomainBlockController, :delete)
498 get("/filters", FilterController, :index)
500 post("/filters", FilterController, :create)
501 get("/filters/:id", FilterController, :show)
502 put("/filters/:id", FilterController, :update)
503 delete("/filters/:id", FilterController, :delete)
505 get("/follow_requests", FollowRequestController, :index)
506 post("/follow_requests/:id/authorize", FollowRequestController, :authorize)
507 post("/follow_requests/:id/reject", FollowRequestController, :reject)
509 get("/lists", ListController, :index)
510 get("/lists/:id", ListController, :show)
511 get("/lists/:id/accounts", ListController, :list_accounts)
513 delete("/lists/:id", ListController, :delete)
514 post("/lists", ListController, :create)
515 put("/lists/:id", ListController, :update)
516 post("/lists/:id/accounts", ListController, :add_to_list)
517 delete("/lists/:id/accounts", ListController, :remove_from_list)
519 get("/markers", MarkerController, :index)
520 post("/markers", MarkerController, :upsert)
522 post("/media", MediaController, :create)
523 get("/media/:id", MediaController, :show)
524 put("/media/:id", MediaController, :update)
526 get("/notifications", NotificationController, :index)
527 get("/notifications/:id", NotificationController, :show)
529 post("/notifications/:id/dismiss", NotificationController, :dismiss)
530 post("/notifications/clear", NotificationController, :clear)
531 delete("/notifications/destroy_multiple", NotificationController, :destroy_multiple)
532 # Deprecated: was removed in Mastodon v3, use `/notifications/:id/dismiss` instead
533 post("/notifications/dismiss", NotificationController, :dismiss_via_body)
535 post("/polls/:id/votes", PollController, :vote)
537 post("/reports", ReportController, :create)
539 get("/scheduled_statuses", ScheduledActivityController, :index)
540 get("/scheduled_statuses/:id", ScheduledActivityController, :show)
542 put("/scheduled_statuses/:id", ScheduledActivityController, :update)
543 delete("/scheduled_statuses/:id", ScheduledActivityController, :delete)
545 # Unlike `GET /api/v1/accounts/:id/favourites`, demands authentication
546 get("/favourites", StatusController, :favourites)
547 get("/bookmarks", StatusController, :bookmarks)
549 post("/statuses", StatusController, :create)
550 delete("/statuses/:id", StatusController, :delete)
551 post("/statuses/:id/reblog", StatusController, :reblog)
552 post("/statuses/:id/unreblog", StatusController, :unreblog)
553 post("/statuses/:id/favourite", StatusController, :favourite)
554 post("/statuses/:id/unfavourite", StatusController, :unfavourite)
555 post("/statuses/:id/pin", StatusController, :pin)
556 post("/statuses/:id/unpin", StatusController, :unpin)
557 post("/statuses/:id/bookmark", StatusController, :bookmark)
558 post("/statuses/:id/unbookmark", StatusController, :unbookmark)
559 post("/statuses/:id/mute", StatusController, :mute_conversation)
560 post("/statuses/:id/unmute", StatusController, :unmute_conversation)
562 post("/push/subscription", SubscriptionController, :create)
563 get("/push/subscription", SubscriptionController, :show)
564 put("/push/subscription", SubscriptionController, :update)
565 delete("/push/subscription", SubscriptionController, :delete)
567 get("/suggestions", SuggestionController, :index)
568 delete("/suggestions/:account_id", SuggestionController, :dismiss)
570 get("/timelines/home", TimelineController, :home)
571 get("/timelines/direct", TimelineController, :direct)
572 get("/timelines/list/:list_id", TimelineController, :list)
575 scope "/api/v1", Pleroma.Web.MastodonAPI do
576 pipe_through(:app_api)
578 post("/apps", AppController, :create)
579 get("/apps/verify_credentials", AppController, :verify_credentials)
582 scope "/api/v1", Pleroma.Web.MastodonAPI do
585 get("/accounts/search", SearchController, :account_search)
586 get("/search", SearchController, :search)
588 get("/accounts/lookup", AccountController, :lookup)
590 get("/accounts/:id/statuses", AccountController, :statuses)
591 get("/accounts/:id/followers", AccountController, :followers)
592 get("/accounts/:id/following", AccountController, :following)
593 get("/accounts/:id", AccountController, :show)
595 post("/accounts", AccountController, :create)
597 get("/instance", InstanceController, :show)
598 get("/instance/peers", InstanceController, :peers)
600 get("/statuses", StatusController, :index)
601 get("/statuses/:id", StatusController, :show)
602 get("/statuses/:id/context", StatusController, :context)
603 get("/statuses/:id/card", StatusController, :card)
604 get("/statuses/:id/favourited_by", StatusController, :favourited_by)
605 get("/statuses/:id/reblogged_by", StatusController, :reblogged_by)
607 get("/custom_emojis", CustomEmojiController, :index)
609 get("/trends", MastodonAPIController, :empty_array)
611 get("/timelines/public", TimelineController, :public)
612 get("/timelines/tag/:tag", TimelineController, :hashtag)
614 get("/polls/:id", PollController, :show)
616 get("/directory", DirectoryController, :index)
619 scope "/api/v2", Pleroma.Web.MastodonAPI do
621 get("/search", SearchController, :search2)
623 post("/media", MediaController, :create2)
625 get("/suggestions", SuggestionController, :index2)
628 scope "/api", Pleroma.Web do
629 pipe_through(:config)
631 get("/pleroma/frontend_configurations", TwitterAPI.UtilController, :frontend_configurations)
634 scope "/api", Pleroma.Web do
638 "/account/confirm_email/:user_id/:token",
639 TwitterAPI.Controller,
646 pipe_through(:base_api)
648 get("/openapi", OpenApiSpex.Plug.RenderSpec, [])
651 scope "/api", Pleroma.Web, as: :authenticated_twitter_api do
652 pipe_through(:authenticated_api)
654 get("/oauth_tokens", TwitterAPI.Controller, :oauth_tokens)
655 delete("/oauth_tokens/:id", TwitterAPI.Controller, :revoke_token)
658 scope "/", Pleroma.Web do
659 # Note: html format is supported only if static FE is enabled
660 # Note: http signature is only considered for json requests (no auth for non-json requests)
661 pipe_through([:accepts_html_json, :http_signature, :static_fe])
663 get("/objects/:uuid", OStatus.OStatusController, :object)
664 get("/activities/:uuid", OStatus.OStatusController, :activity)
665 get("/notice/:id", OStatus.OStatusController, :notice)
667 # Notice compatibility routes for other frontends
668 get("/@:nickname/:id", OStatus.OStatusController, :notice)
669 get("/@:nickname/posts/:id", OStatus.OStatusController, :notice)
670 get("/:nickname/status/:id", OStatus.OStatusController, :notice)
672 # Mastodon compatibility routes
673 get("/users/:nickname/statuses/:id", OStatus.OStatusController, :object)
674 get("/users/:nickname/statuses/:id/activity", OStatus.OStatusController, :activity)
677 scope "/", Pleroma.Web do
678 # Note: html format is supported only if static FE is enabled
679 # Note: http signature is only considered for json requests (no auth for non-json requests)
680 pipe_through([:accepts_html_xml_json, :http_signature, :static_fe])
682 # Note: returns user _profile_ for json requests, redirects to user _feed_ for non-json ones
683 get("/users/:nickname", Feed.UserController, :feed_redirect, as: :user_feed)
686 scope "/", Pleroma.Web do
687 # Note: html format is supported only if static FE is enabled
688 pipe_through([:accepts_html_xml, :static_fe])
690 get("/users/:nickname/feed", Feed.UserController, :feed, as: :user_feed)
693 scope "/", Pleroma.Web do
694 pipe_through(:accepts_html)
695 get("/notice/:id/embed_player", OStatus.OStatusController, :notice_player)
698 scope "/", Pleroma.Web do
699 pipe_through(:accepts_xml_rss_atom)
700 get("/tags/:tag", Feed.TagController, :feed, as: :tag_feed)
703 scope "/", Pleroma.Web do
704 pipe_through(:browser)
705 get("/mailer/unsubscribe/:token", Mailer.SubscriptionController, :unsubscribe)
708 pipeline :ap_service_actor do
709 plug(:accepts, ["activity+json", "json"])
712 # Server to Server (S2S) AP interactions
713 pipeline :activitypub do
714 plug(:ap_service_actor)
715 plug(:http_signature)
718 # Client to Server (C2S) AP interactions
719 pipeline :activitypub_client do
720 plug(:ap_service_actor)
726 scope "/", Pleroma.Web.ActivityPub do
727 pipe_through([:activitypub_client])
729 get("/api/ap/whoami", ActivityPubController, :whoami)
730 get("/users/:nickname/inbox", ActivityPubController, :read_inbox)
732 get("/users/:nickname/outbox", ActivityPubController, :outbox)
733 post("/users/:nickname/outbox", ActivityPubController, :update_outbox)
734 post("/api/ap/upload_media", ActivityPubController, :upload_media)
736 # The following two are S2S as well, see `ActivityPub.fetch_follow_information_for_user/1`:
737 get("/users/:nickname/followers", ActivityPubController, :followers)
738 get("/users/:nickname/following", ActivityPubController, :following)
739 get("/users/:nickname/collections/featured", ActivityPubController, :pinned)
742 scope "/", Pleroma.Web.ActivityPub do
743 pipe_through(:activitypub)
744 post("/inbox", ActivityPubController, :inbox)
745 post("/users/:nickname/inbox", ActivityPubController, :inbox)
748 scope "/relay", Pleroma.Web.ActivityPub do
749 pipe_through(:ap_service_actor)
751 get("/", ActivityPubController, :relay)
754 pipe_through(:http_signature)
755 post("/inbox", ActivityPubController, :inbox)
758 get("/following", ActivityPubController, :relay_following)
759 get("/followers", ActivityPubController, :relay_followers)
762 scope "/internal/fetch", Pleroma.Web.ActivityPub do
763 pipe_through(:ap_service_actor)
765 get("/", ActivityPubController, :internal_fetch)
766 post("/inbox", ActivityPubController, :inbox)
769 scope "/.well-known", Pleroma.Web do
770 pipe_through(:well_known)
772 get("/host-meta", WebFinger.WebFingerController, :host_meta)
773 get("/webfinger", WebFinger.WebFingerController, :webfinger)
774 get("/nodeinfo", Nodeinfo.NodeinfoController, :schemas)
777 scope "/nodeinfo", Pleroma.Web do
778 get("/:version", Nodeinfo.NodeinfoController, :nodeinfo)
781 scope "/", Pleroma.Web do
784 get("/manifest.json", ManifestController, :show)
787 scope "/", Pleroma.Web do
788 pipe_through(:pleroma_html)
790 post("/auth/password", TwitterAPI.PasswordController, :request)
793 scope "/proxy/", Pleroma.Web do
794 get("/preview/:sig/:url", MediaProxy.MediaProxyController, :preview)
795 get("/preview/:sig/:url/:filename", MediaProxy.MediaProxyController, :preview)
796 get("/:sig/:url", MediaProxy.MediaProxyController, :remote)
797 get("/:sig/:url/:filename", MediaProxy.MediaProxyController, :remote)
800 if Pleroma.Config.get(:env) == :dev do
802 pipe_through([:mailbox_preview])
804 forward("/mailbox", Plug.Swoosh.MailboxPreview, base_path: "/dev/mailbox")
809 pipe_through([:pleroma_html, :authenticate, :require_admin])
810 live_dashboard("/phoenix/live_dashboard")
813 # Test-only routes needed to test action dispatching and plug chain execution
814 if Pleroma.Config.get(:env) == :test do
817 :fallback_oauth_check,
819 :fallback_oauth_skip_publicity_check,
820 :skip_oauth_skip_publicity_check,
821 :missing_oauth_check_definition
824 scope "/test/api", Pleroma.Tests do
827 for action <- @test_actions do
828 get("/#{action}", AuthTestController, action)
832 scope "/test/authenticated_api", Pleroma.Tests do
833 pipe_through(:authenticated_api)
835 for action <- @test_actions do
836 get("/#{action}", AuthTestController, action)
841 scope "/", Pleroma.Web.MongooseIM do
842 get("/user_exists", MongooseIMController, :user_exists)
843 get("/check_password", MongooseIMController, :check_password)
846 scope "/", Pleroma.Web.Fallback do
847 get("/registration/:token", RedirectController, :registration_page)
848 get("/:maybe_nickname_or_id", RedirectController, :redirector_with_meta)
849 match(:*, "/api/pleroma*path", LegacyPleromaApiRerouterPlug, [])
850 get("/api*path", RedirectController, :api_not_implemented)
851 get("/*path", RedirectController, :redirector_with_preload)
853 options("/*path", RedirectController, :empty)
856 # TODO: Change to Phoenix.Router.routes/1 for Phoenix 1.6.0+
857 def get_api_routes do
858 __MODULE__.__routes__()
859 |> Enum.reject(fn r -> r.plug == Pleroma.Web.Fallback.RedirectController end)
862 |> String.split("/", trim: true)