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_admin do
105 plug(Pleroma.Web.Plugs.UserIsAdminPlug)
108 pipeline :pleroma_html do
111 plug(Pleroma.Web.Plugs.EnsureUserTokenAssignsPlug)
114 pipeline :well_known do
115 plug(:accepts, ["json", "jrd+json", "xml", "xrd+xml"])
119 plug(:accepts, ["json", "xml"])
120 plug(OpenApiSpex.Plug.PutApiSpec, module: Pleroma.Web.ApiSpec)
123 pipeline :pleroma_api do
124 plug(:accepts, ["html", "json"])
125 plug(OpenApiSpex.Plug.PutApiSpec, module: Pleroma.Web.ApiSpec)
128 pipeline :mailbox_preview do
129 plug(:accepts, ["html"])
131 plug(:put_secure_browser_headers, %{
132 "content-security-policy" =>
133 "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline' 'unsafe-eval'"
137 pipeline :http_signature do
138 plug(Pleroma.Web.Plugs.HTTPSignaturePlug)
139 plug(Pleroma.Web.Plugs.MappedSignatureToIdentityPlug)
142 pipeline :static_fe do
143 plug(Pleroma.Web.Plugs.StaticFEPlug)
146 scope "/api/v1/pleroma", Pleroma.Web.TwitterAPI do
147 pipe_through(:pleroma_api)
149 get("/password_reset/:token", PasswordController, :reset, as: :reset_password)
150 post("/password_reset", PasswordController, :do_reset, as: :reset_password)
151 get("/emoji", UtilController, :emoji)
152 get("/captcha", UtilController, :captcha)
153 get("/healthcheck", UtilController, :healthcheck)
156 scope "/api/v1/pleroma", Pleroma.Web do
157 pipe_through(:pleroma_api)
158 post("/uploader_callback/:upload_path", UploaderController, :callback)
161 scope "/api/v1/pleroma/admin", Pleroma.Web.AdminAPI do
162 pipe_through([:admin_api, :require_admin])
164 put("/users/disable_mfa", AdminAPIController, :disable_mfa)
165 put("/users/tag", AdminAPIController, :tag_users)
166 delete("/users/tag", AdminAPIController, :untag_users)
168 get("/users/:nickname/permission_group", AdminAPIController, :right_get)
169 get("/users/:nickname/permission_group/:permission_group", AdminAPIController, :right_get)
171 post("/users/:nickname/permission_group/:permission_group", AdminAPIController, :right_add)
174 "/users/:nickname/permission_group/:permission_group",
179 post("/users/permission_group/:permission_group", AdminAPIController, :right_add_multiple)
182 "/users/permission_group/:permission_group",
184 :right_delete_multiple
187 post("/users/follow", UserController, :follow)
188 post("/users/unfollow", UserController, :unfollow)
189 delete("/users", UserController, :delete)
190 post("/users", UserController, :create)
191 patch("/users/:nickname/toggle_activation", UserController, :toggle_activation)
192 patch("/users/activate", UserController, :activate)
193 patch("/users/deactivate", UserController, :deactivate)
194 patch("/users/approve", UserController, :approve)
196 patch("/users/suggest", UserController, :suggest)
197 patch("/users/unsuggest", UserController, :unsuggest)
199 get("/relay", RelayController, :index)
200 post("/relay", RelayController, :follow)
201 delete("/relay", RelayController, :unfollow)
203 post("/users/invite_token", InviteController, :create)
204 get("/users/invites", InviteController, :index)
205 post("/users/revoke_invite", InviteController, :revoke)
206 post("/users/email_invite", InviteController, :email)
208 get("/users/:nickname/password_reset", AdminAPIController, :get_password_reset)
209 patch("/users/force_password_reset", AdminAPIController, :force_password_reset)
210 get("/users/:nickname/credentials", AdminAPIController, :show_user_credentials)
211 patch("/users/:nickname/credentials", AdminAPIController, :update_user_credentials)
213 get("/users", UserController, :index)
214 get("/users/:nickname", UserController, :show)
215 get("/users/:nickname/statuses", AdminAPIController, :list_user_statuses)
216 get("/users/:nickname/chats", AdminAPIController, :list_user_chats)
218 get("/instances/:instance/statuses", InstanceController, :list_statuses)
219 delete("/instances/:instance", InstanceController, :delete)
221 get("/instance_document/:name", InstanceDocumentController, :show)
222 patch("/instance_document/:name", InstanceDocumentController, :update)
223 delete("/instance_document/:name", InstanceDocumentController, :delete)
225 patch("/users/confirm_email", AdminAPIController, :confirm_email)
226 patch("/users/resend_confirmation_email", AdminAPIController, :resend_confirmation_email)
228 get("/reports", ReportController, :index)
229 get("/reports/:id", ReportController, :show)
230 patch("/reports", ReportController, :update)
231 post("/reports/:id/notes", ReportController, :notes_create)
232 delete("/reports/:report_id/notes/:id", ReportController, :notes_delete)
234 get("/statuses/:id", StatusController, :show)
235 put("/statuses/:id", StatusController, :update)
236 delete("/statuses/:id", StatusController, :delete)
237 get("/statuses", StatusController, :index)
239 get("/config", ConfigController, :show)
240 post("/config", ConfigController, :update)
241 get("/config/descriptions", ConfigController, :descriptions)
242 get("/need_reboot", AdminAPIController, :need_reboot)
243 get("/restart", AdminAPIController, :restart)
245 get("/moderation_log", AdminAPIController, :list_log)
247 post("/reload_emoji", AdminAPIController, :reload_emoji)
248 get("/stats", AdminAPIController, :stats)
250 get("/oauth_app", OAuthAppController, :index)
251 post("/oauth_app", OAuthAppController, :create)
252 patch("/oauth_app/:id", OAuthAppController, :update)
253 delete("/oauth_app/:id", OAuthAppController, :delete)
255 get("/media_proxy_caches", MediaProxyCacheController, :index)
256 post("/media_proxy_caches/delete", MediaProxyCacheController, :delete)
257 post("/media_proxy_caches/purge", MediaProxyCacheController, :purge)
259 get("/chats/:id", ChatController, :show)
260 get("/chats/:id/messages", ChatController, :messages)
261 delete("/chats/:id/messages/:message_id", ChatController, :delete_message)
263 get("/frontends", FrontendController, :index)
264 post("/frontends/install", FrontendController, :install)
266 post("/backups", AdminAPIController, :create_backup)
269 scope "/api/v1/pleroma/emoji", Pleroma.Web.PleromaAPI do
271 pipe_through([:admin_api, :require_admin])
273 post("/", EmojiPackController, :create)
274 patch("/", EmojiPackController, :update)
275 delete("/", EmojiPackController, :delete)
281 get("/", EmojiPackController, :show)
286 pipe_through([:admin_api, :require_admin])
288 get("/import", EmojiPackController, :import_from_filesystem)
289 get("/remote", EmojiPackController, :remote)
290 post("/download", EmojiPackController, :download)
292 post("/files", EmojiFileController, :create)
293 patch("/files", EmojiFileController, :update)
294 delete("/files", EmojiFileController, :delete)
297 # Pack info / downloading
301 get("/", EmojiPackController, :index)
302 get("/archive", EmojiPackController, :archive)
306 scope "/", Pleroma.Web.TwitterAPI do
307 pipe_through(:pleroma_html)
309 post("/main/ostatus", UtilController, :remote_subscribe)
310 get("/ostatus_subscribe", RemoteFollowController, :follow)
311 post("/ostatus_subscribe", RemoteFollowController, :do_follow)
314 scope "/api/pleroma", Pleroma.Web.TwitterAPI do
315 pipe_through(:authenticated_api)
317 post("/change_email", UtilController, :change_email)
318 post("/change_password", UtilController, :change_password)
319 post("/delete_account", UtilController, :delete_account)
320 put("/notification_settings", UtilController, :update_notificaton_settings)
321 post("/disable_account", UtilController, :disable_account)
324 scope "/api/pleroma", Pleroma.Web.PleromaAPI do
325 pipe_through(:authenticated_api)
327 post("/mutes_import", UserImportController, :mutes)
328 post("/blocks_import", UserImportController, :blocks)
329 post("/follow_import", UserImportController, :follow)
331 get("/accounts/mfa", TwoFactorAuthenticationController, :settings)
332 get("/accounts/mfa/backup_codes", TwoFactorAuthenticationController, :backup_codes)
333 get("/accounts/mfa/setup/:method", TwoFactorAuthenticationController, :setup)
334 post("/accounts/mfa/confirm/:method", TwoFactorAuthenticationController, :confirm)
335 delete("/accounts/mfa/:method", TwoFactorAuthenticationController, :disable)
338 scope "/oauth", Pleroma.Web.OAuth do
339 # Note: use /api/v1/accounts/verify_credentials for userinfo of signed-in user
341 get("/registration_details", OAuthController, :registration_details)
343 post("/mfa/verify", MFAController, :verify, as: :mfa_verify)
344 get("/mfa", MFAController, :show)
349 get("/authorize", OAuthController, :authorize)
350 post("/authorize", OAuthController, :create_authorization)
354 pipe_through(:fetch_session)
356 post("/token", OAuthController, :token_exchange)
357 post("/revoke", OAuthController, :token_revoke)
358 post("/mfa/challenge", MFAController, :challenge)
362 pipe_through(:browser)
364 get("/prepare_request", OAuthController, :prepare_request)
365 get("/:provider", OAuthController, :request)
366 get("/:provider/callback", OAuthController, :callback)
367 post("/register", OAuthController, :register)
371 scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do
374 get("/statuses/:id/reactions/:emoji", EmojiReactionController, :index)
375 get("/statuses/:id/reactions", EmojiReactionController, :index)
378 scope "/api/v0/pleroma", Pleroma.Web.PleromaAPI do
379 pipe_through(:authenticated_api)
380 get("/reports", ReportController, :index)
381 get("/reports/:id", ReportController, :show)
384 scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do
386 pipe_through(:authenticated_api)
388 post("/chats/by-account-id/:id", ChatController, :create)
389 get("/chats", ChatController, :index)
390 get("/chats/:id", ChatController, :show)
391 get("/chats/:id/messages", ChatController, :messages)
392 post("/chats/:id/messages", ChatController, :post_chat_message)
393 delete("/chats/:id/messages/:message_id", ChatController, :delete_message)
394 post("/chats/:id/read", ChatController, :mark_as_read)
395 post("/chats/:id/messages/:message_id/read", ChatController, :mark_message_as_read)
397 get("/conversations/:id/statuses", ConversationController, :statuses)
398 get("/conversations/:id", ConversationController, :show)
399 post("/conversations/read", ConversationController, :mark_as_read)
400 patch("/conversations/:id", ConversationController, :update)
402 put("/statuses/:id/reactions/:emoji", EmojiReactionController, :create)
403 delete("/statuses/:id/reactions/:emoji", EmojiReactionController, :delete)
404 post("/notifications/read", NotificationController, :mark_as_read)
406 get("/mascot", MascotController, :show)
407 put("/mascot", MascotController, :update)
409 post("/scrobble", ScrobbleController, :create)
411 get("/backups", BackupController, :index)
412 post("/backups", BackupController, :create)
417 get("/accounts/:id/favourites", AccountController, :favourites)
421 pipe_through(:authenticated_api)
423 post("/accounts/:id/subscribe", AccountController, :subscribe)
424 post("/accounts/:id/unsubscribe", AccountController, :unsubscribe)
427 post("/accounts/confirmation_resend", AccountController, :confirmation_resend)
430 scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do
432 get("/accounts/:id/scrobbles", ScrobbleController, :index)
433 get("/federation_status", InstancesController, :show)
436 scope "/api/v2/pleroma", Pleroma.Web.PleromaAPI do
438 pipe_through(:authenticated_api)
439 get("/chats", ChatController, :index2)
443 scope "/api/v1", Pleroma.Web.MastodonAPI do
444 pipe_through(:authenticated_api)
446 get("/accounts/verify_credentials", AccountController, :verify_credentials)
447 patch("/accounts/update_credentials", AccountController, :update_credentials)
449 get("/accounts/relationships", AccountController, :relationships)
450 get("/accounts/:id/lists", AccountController, :lists)
451 get("/accounts/:id/identity_proofs", AccountController, :identity_proofs)
452 get("/endorsements", AccountController, :endorsements)
453 get("/blocks", AccountController, :blocks)
454 get("/mutes", AccountController, :mutes)
456 post("/follows", AccountController, :follow_by_uri)
457 post("/accounts/:id/follow", AccountController, :follow)
458 post("/accounts/:id/unfollow", AccountController, :unfollow)
459 post("/accounts/:id/block", AccountController, :block)
460 post("/accounts/:id/unblock", AccountController, :unblock)
461 post("/accounts/:id/mute", AccountController, :mute)
462 post("/accounts/:id/unmute", AccountController, :unmute)
464 get("/conversations", ConversationController, :index)
465 post("/conversations/:id/read", ConversationController, :mark_as_read)
466 delete("/conversations/:id", ConversationController, :delete)
468 get("/domain_blocks", DomainBlockController, :index)
469 post("/domain_blocks", DomainBlockController, :create)
470 delete("/domain_blocks", DomainBlockController, :delete)
472 get("/filters", FilterController, :index)
474 post("/filters", FilterController, :create)
475 get("/filters/:id", FilterController, :show)
476 put("/filters/:id", FilterController, :update)
477 delete("/filters/:id", FilterController, :delete)
479 get("/follow_requests", FollowRequestController, :index)
480 post("/follow_requests/:id/authorize", FollowRequestController, :authorize)
481 post("/follow_requests/:id/reject", FollowRequestController, :reject)
483 get("/lists", ListController, :index)
484 get("/lists/:id", ListController, :show)
485 get("/lists/:id/accounts", ListController, :list_accounts)
487 delete("/lists/:id", ListController, :delete)
488 post("/lists", ListController, :create)
489 put("/lists/:id", ListController, :update)
490 post("/lists/:id/accounts", ListController, :add_to_list)
491 delete("/lists/:id/accounts", ListController, :remove_from_list)
493 get("/markers", MarkerController, :index)
494 post("/markers", MarkerController, :upsert)
496 post("/media", MediaController, :create)
497 get("/media/:id", MediaController, :show)
498 put("/media/:id", MediaController, :update)
500 get("/notifications", NotificationController, :index)
501 get("/notifications/:id", NotificationController, :show)
503 post("/notifications/:id/dismiss", NotificationController, :dismiss)
504 post("/notifications/clear", NotificationController, :clear)
505 delete("/notifications/destroy_multiple", NotificationController, :destroy_multiple)
506 # Deprecated: was removed in Mastodon v3, use `/notifications/:id/dismiss` instead
507 post("/notifications/dismiss", NotificationController, :dismiss_via_body)
509 post("/polls/:id/votes", PollController, :vote)
511 post("/reports", ReportController, :create)
513 get("/scheduled_statuses", ScheduledActivityController, :index)
514 get("/scheduled_statuses/:id", ScheduledActivityController, :show)
516 put("/scheduled_statuses/:id", ScheduledActivityController, :update)
517 delete("/scheduled_statuses/:id", ScheduledActivityController, :delete)
519 # Unlike `GET /api/v1/accounts/:id/favourites`, demands authentication
520 get("/favourites", StatusController, :favourites)
521 get("/bookmarks", StatusController, :bookmarks)
523 post("/statuses", StatusController, :create)
524 delete("/statuses/:id", StatusController, :delete)
525 post("/statuses/:id/reblog", StatusController, :reblog)
526 post("/statuses/:id/unreblog", StatusController, :unreblog)
527 post("/statuses/:id/favourite", StatusController, :favourite)
528 post("/statuses/:id/unfavourite", StatusController, :unfavourite)
529 post("/statuses/:id/pin", StatusController, :pin)
530 post("/statuses/:id/unpin", StatusController, :unpin)
531 post("/statuses/:id/bookmark", StatusController, :bookmark)
532 post("/statuses/:id/unbookmark", StatusController, :unbookmark)
533 post("/statuses/:id/mute", StatusController, :mute_conversation)
534 post("/statuses/:id/unmute", StatusController, :unmute_conversation)
536 post("/push/subscription", SubscriptionController, :create)
537 get("/push/subscription", SubscriptionController, :show)
538 put("/push/subscription", SubscriptionController, :update)
539 delete("/push/subscription", SubscriptionController, :delete)
541 get("/suggestions", SuggestionController, :index)
542 delete("/suggestions/:account_id", SuggestionController, :dismiss)
544 get("/timelines/home", TimelineController, :home)
545 get("/timelines/direct", TimelineController, :direct)
546 get("/timelines/list/:list_id", TimelineController, :list)
549 scope "/api/v1", Pleroma.Web.MastodonAPI do
550 pipe_through(:app_api)
552 post("/apps", AppController, :create)
553 get("/apps/verify_credentials", AppController, :verify_credentials)
556 scope "/api/v1", Pleroma.Web.MastodonAPI do
559 get("/accounts/search", SearchController, :account_search)
560 get("/search", SearchController, :search)
562 get("/accounts/:id/statuses", AccountController, :statuses)
563 get("/accounts/:id/followers", AccountController, :followers)
564 get("/accounts/:id/following", AccountController, :following)
565 get("/accounts/:id", AccountController, :show)
567 post("/accounts", AccountController, :create)
569 get("/instance", InstanceController, :show)
570 get("/instance/peers", InstanceController, :peers)
572 get("/statuses", StatusController, :index)
573 get("/statuses/:id", StatusController, :show)
574 get("/statuses/:id/context", StatusController, :context)
575 get("/statuses/:id/card", StatusController, :card)
576 get("/statuses/:id/favourited_by", StatusController, :favourited_by)
577 get("/statuses/:id/reblogged_by", StatusController, :reblogged_by)
579 get("/custom_emojis", CustomEmojiController, :index)
581 get("/trends", MastodonAPIController, :empty_array)
583 get("/timelines/public", TimelineController, :public)
584 get("/timelines/tag/:tag", TimelineController, :hashtag)
586 get("/polls/:id", PollController, :show)
589 scope "/api/v2", Pleroma.Web.MastodonAPI do
591 get("/search", SearchController, :search2)
593 post("/media", MediaController, :create2)
595 get("/suggestions", SuggestionController, :index2)
598 scope "/api", Pleroma.Web do
599 pipe_through(:config)
601 get("/pleroma/frontend_configurations", TwitterAPI.UtilController, :frontend_configurations)
604 scope "/api", Pleroma.Web do
608 "/account/confirm_email/:user_id/:token",
609 TwitterAPI.Controller,
616 pipe_through(:base_api)
618 get("/openapi", OpenApiSpex.Plug.RenderSpec, [])
621 scope "/api", Pleroma.Web, as: :authenticated_twitter_api do
622 pipe_through(:authenticated_api)
624 get("/oauth_tokens", TwitterAPI.Controller, :oauth_tokens)
625 delete("/oauth_tokens/:id", TwitterAPI.Controller, :revoke_token)
628 scope "/", Pleroma.Web do
629 # Note: html format is supported only if static FE is enabled
630 # Note: http signature is only considered for json requests (no auth for non-json requests)
631 pipe_through([:accepts_html_json, :http_signature, :static_fe])
633 get("/objects/:uuid", OStatus.OStatusController, :object)
634 get("/activities/:uuid", OStatus.OStatusController, :activity)
635 get("/notice/:id", OStatus.OStatusController, :notice)
637 # Mastodon compatibility routes
638 get("/users/:nickname/statuses/:id", OStatus.OStatusController, :object)
639 get("/users/:nickname/statuses/:id/activity", OStatus.OStatusController, :activity)
642 scope "/", Pleroma.Web do
643 # Note: html format is supported only if static FE is enabled
644 # Note: http signature is only considered for json requests (no auth for non-json requests)
645 pipe_through([:accepts_html_xml_json, :http_signature, :static_fe])
647 # Note: returns user _profile_ for json requests, redirects to user _feed_ for non-json ones
648 get("/users/:nickname", Feed.UserController, :feed_redirect, as: :user_feed)
651 scope "/", Pleroma.Web do
652 # Note: html format is supported only if static FE is enabled
653 pipe_through([:accepts_html_xml, :static_fe])
655 get("/users/:nickname/feed", Feed.UserController, :feed, as: :user_feed)
658 scope "/", Pleroma.Web do
659 pipe_through(:accepts_html)
660 get("/notice/:id/embed_player", OStatus.OStatusController, :notice_player)
663 scope "/", Pleroma.Web do
664 pipe_through(:accepts_xml_rss_atom)
665 get("/tags/:tag", Feed.TagController, :feed, as: :tag_feed)
668 scope "/", Pleroma.Web do
669 pipe_through(:browser)
670 get("/mailer/unsubscribe/:token", Mailer.SubscriptionController, :unsubscribe)
673 pipeline :ap_service_actor do
674 plug(:accepts, ["activity+json", "json"])
677 # Server to Server (S2S) AP interactions
678 pipeline :activitypub do
679 plug(:ap_service_actor)
680 plug(:http_signature)
683 # Client to Server (C2S) AP interactions
684 pipeline :activitypub_client do
685 plug(:ap_service_actor)
691 scope "/", Pleroma.Web.ActivityPub do
692 pipe_through([:activitypub_client])
694 get("/api/ap/whoami", ActivityPubController, :whoami)
695 get("/users/:nickname/inbox", ActivityPubController, :read_inbox)
697 get("/users/:nickname/outbox", ActivityPubController, :outbox)
698 post("/users/:nickname/outbox", ActivityPubController, :update_outbox)
699 post("/api/ap/upload_media", ActivityPubController, :upload_media)
701 # The following two are S2S as well, see `ActivityPub.fetch_follow_information_for_user/1`:
702 get("/users/:nickname/followers", ActivityPubController, :followers)
703 get("/users/:nickname/following", ActivityPubController, :following)
704 get("/users/:nickname/collections/featured", ActivityPubController, :pinned)
707 scope "/", Pleroma.Web.ActivityPub do
708 pipe_through(:activitypub)
709 post("/inbox", ActivityPubController, :inbox)
710 post("/users/:nickname/inbox", ActivityPubController, :inbox)
713 scope "/relay", Pleroma.Web.ActivityPub do
714 pipe_through(:ap_service_actor)
716 get("/", ActivityPubController, :relay)
719 pipe_through(:http_signature)
720 post("/inbox", ActivityPubController, :inbox)
723 get("/following", ActivityPubController, :relay_following)
724 get("/followers", ActivityPubController, :relay_followers)
727 scope "/internal/fetch", Pleroma.Web.ActivityPub do
728 pipe_through(:ap_service_actor)
730 get("/", ActivityPubController, :internal_fetch)
731 post("/inbox", ActivityPubController, :inbox)
734 scope "/.well-known", Pleroma.Web do
735 pipe_through(:well_known)
737 get("/host-meta", WebFinger.WebFingerController, :host_meta)
738 get("/webfinger", WebFinger.WebFingerController, :webfinger)
739 get("/nodeinfo", Nodeinfo.NodeinfoController, :schemas)
742 scope "/nodeinfo", Pleroma.Web do
743 get("/:version", Nodeinfo.NodeinfoController, :nodeinfo)
746 scope "/", Pleroma.Web do
749 get("/manifest.json", ManifestController, :show)
752 scope "/", Pleroma.Web do
753 pipe_through(:pleroma_html)
755 post("/auth/password", TwitterAPI.PasswordController, :request)
758 scope "/proxy/", Pleroma.Web do
759 get("/preview/:sig/:url", MediaProxy.MediaProxyController, :preview)
760 get("/preview/:sig/:url/:filename", MediaProxy.MediaProxyController, :preview)
761 get("/:sig/:url", MediaProxy.MediaProxyController, :remote)
762 get("/:sig/:url/:filename", MediaProxy.MediaProxyController, :remote)
765 if Pleroma.Config.get(:env) == :dev do
767 pipe_through([:mailbox_preview])
769 forward("/mailbox", Plug.Swoosh.MailboxPreview, base_path: "/dev/mailbox")
774 pipe_through([:pleroma_html, :authenticate, :require_admin])
775 live_dashboard("/phoenix/live_dashboard")
778 # Test-only routes needed to test action dispatching and plug chain execution
779 if Pleroma.Config.get(:env) == :test do
782 :fallback_oauth_check,
784 :fallback_oauth_skip_publicity_check,
785 :skip_oauth_skip_publicity_check,
786 :missing_oauth_check_definition
789 scope "/test/api", Pleroma.Tests do
792 for action <- @test_actions do
793 get("/#{action}", AuthTestController, action)
797 scope "/test/authenticated_api", Pleroma.Tests do
798 pipe_through(:authenticated_api)
800 for action <- @test_actions do
801 get("/#{action}", AuthTestController, action)
806 scope "/", Pleroma.Web.MongooseIM do
807 get("/user_exists", MongooseIMController, :user_exists)
808 get("/check_password", MongooseIMController, :check_password)
811 scope "/", Pleroma.Web.Fallback do
812 get("/registration/:token", RedirectController, :registration_page)
813 get("/:maybe_nickname_or_id", RedirectController, :redirector_with_meta)
814 match(:*, "/api/pleroma*path", LegacyPleromaApiRerouterPlug, [])
815 get("/api*path", RedirectController, :api_not_implemented)
816 get("/*path", RedirectController, :redirector_with_preload)
818 options("/*path", RedirectController, :empty)
821 # TODO: Change to Phoenix.Router.routes/1 for Phoenix 1.6.0+
822 def get_api_routes do
823 __MODULE__.__routes__()
824 |> Enum.reject(fn r -> r.plug == Pleroma.Web.Fallback.RedirectController end)
827 |> String.split("/", trim: true)