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", "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.PleromaAPI do
228 pipe_through(:pleroma_api)
230 get("/federation_status", InstancesController, :show)
233 scope "/api/v1/pleroma", Pleroma.Web do
234 pipe_through(:pleroma_api)
235 post("/uploader_callback/:upload_path", UploaderController, :callback)
238 # AdminAPI: only admins can perform these actions
239 scope "/api/v1/pleroma/admin", Pleroma.Web.AdminAPI do
240 pipe_through([:admin_api, :require_admin])
242 get("/users/:nickname/permission_group", AdminAPIController, :right_get)
243 get("/users/:nickname/permission_group/:permission_group", AdminAPIController, :right_get)
245 post("/users/:nickname/permission_group/:permission_group", AdminAPIController, :right_add)
248 "/users/:nickname/permission_group/:permission_group",
253 post("/users/permission_group/:permission_group", AdminAPIController, :right_add_multiple)
256 "/users/permission_group/:permission_group",
258 :right_delete_multiple
261 post("/users/follow", UserController, :follow)
262 post("/users/unfollow", UserController, :unfollow)
263 post("/users", UserController, :create)
265 patch("/users/suggest", UserController, :suggest)
266 patch("/users/unsuggest", UserController, :unsuggest)
268 get("/relay", RelayController, :index)
269 post("/relay", RelayController, :follow)
270 delete("/relay", RelayController, :unfollow)
272 get("/instance_document/:name", InstanceDocumentController, :show)
273 patch("/instance_document/:name", InstanceDocumentController, :update)
274 delete("/instance_document/:name", InstanceDocumentController, :delete)
276 get("/config", ConfigController, :show)
277 post("/config", ConfigController, :update)
278 get("/config/descriptions", ConfigController, :descriptions)
279 get("/need_reboot", AdminAPIController, :need_reboot)
280 get("/restart", AdminAPIController, :restart)
282 get("/oauth_app", OAuthAppController, :index)
283 post("/oauth_app", OAuthAppController, :create)
284 patch("/oauth_app/:id", OAuthAppController, :update)
285 delete("/oauth_app/:id", OAuthAppController, :delete)
287 get("/media_proxy_caches", MediaProxyCacheController, :index)
288 post("/media_proxy_caches/delete", MediaProxyCacheController, :delete)
289 post("/media_proxy_caches/purge", MediaProxyCacheController, :purge)
291 get("/frontends", FrontendController, :index)
292 post("/frontends/install", FrontendController, :install)
294 post("/backups", AdminAPIController, :create_backup)
297 # AdminAPI: admins and mods (staff) can perform these actions (if privileged by role)
298 scope "/api/v1/pleroma/admin", Pleroma.Web.AdminAPI do
299 pipe_through(:require_privileged_role_announcements_manage_announcements)
301 get("/announcements", AnnouncementController, :index)
302 post("/announcements", AnnouncementController, :create)
303 get("/announcements/:id", AnnouncementController, :show)
304 patch("/announcements/:id", AnnouncementController, :change)
305 delete("/announcements/:id", AnnouncementController, :delete)
308 # AdminAPI: admins and mods (staff) can perform these actions (if privileged by role)
309 scope "/api/v1/pleroma/admin", Pleroma.Web.AdminAPI do
310 pipe_through(:require_privileged_role_users_delete)
312 delete("/users", UserController, :delete)
315 # AdminAPI: admins and mods (staff) can perform these actions (if privileged by role)
316 scope "/api/v1/pleroma/admin", Pleroma.Web.AdminAPI do
317 pipe_through(:require_privileged_role_users_manage_credentials)
319 get("/users/:nickname/password_reset", AdminAPIController, :get_password_reset)
320 get("/users/:nickname/credentials", AdminAPIController, :show_user_credentials)
321 patch("/users/:nickname/credentials", AdminAPIController, :update_user_credentials)
322 put("/users/disable_mfa", AdminAPIController, :disable_mfa)
323 patch("/users/force_password_reset", AdminAPIController, :force_password_reset)
324 patch("/users/confirm_email", AdminAPIController, :confirm_email)
325 patch("/users/resend_confirmation_email", AdminAPIController, :resend_confirmation_email)
328 # AdminAPI: admins and mods (staff) can perform these actions (if privileged by role)
329 scope "/api/v1/pleroma/admin", Pleroma.Web.AdminAPI do
330 pipe_through(:require_privileged_role_messages_read)
332 get("/users/:nickname/statuses", AdminAPIController, :list_user_statuses)
333 get("/users/:nickname/chats", AdminAPIController, :list_user_chats)
335 get("/statuses", StatusController, :index)
337 get("/chats/:id", ChatController, :show)
338 get("/chats/:id/messages", ChatController, :messages)
340 get("/instances/:instance/statuses", InstanceController, :list_statuses)
342 get("/statuses/:id", StatusController, :show)
345 # AdminAPI: admins and mods (staff) can perform these actions (if privileged by role)
346 scope "/api/v1/pleroma/admin", Pleroma.Web.AdminAPI do
347 pipe_through(:require_privileged_role_users_manage_tags)
349 put("/users/tag", AdminAPIController, :tag_users)
350 delete("/users/tag", AdminAPIController, :untag_users)
353 # AdminAPI: admins and mods (staff) can perform these actions (if privileged by role)
354 scope "/api/v1/pleroma/admin", Pleroma.Web.AdminAPI do
355 pipe_through(:require_privileged_role_users_manage_activation_state)
357 patch("/users/:nickname/toggle_activation", UserController, :toggle_activation)
358 patch("/users/activate", UserController, :activate)
359 patch("/users/deactivate", UserController, :deactivate)
362 # AdminAPI: admins and mods (staff) can perform these actions (if privileged by role)
363 scope "/api/v1/pleroma/admin", Pleroma.Web.AdminAPI do
364 pipe_through(:require_privileged_role_users_manage_invites)
366 patch("/users/approve", UserController, :approve)
367 post("/users/invite_token", InviteController, :create)
368 get("/users/invites", InviteController, :index)
369 post("/users/revoke_invite", InviteController, :revoke)
370 post("/users/email_invite", InviteController, :email)
373 # AdminAPI: admins and mods (staff) can perform these actions (if privileged by role)
374 scope "/api/v1/pleroma/admin", Pleroma.Web.AdminAPI do
375 pipe_through(:require_privileged_role_reports_manage_reports)
377 get("/reports", ReportController, :index)
378 get("/reports/:id", ReportController, :show)
379 patch("/reports", ReportController, :update)
380 post("/reports/:id/notes", ReportController, :notes_create)
381 delete("/reports/:report_id/notes/:id", ReportController, :notes_delete)
384 # AdminAPI: admins and mods (staff) can perform these actions (if privileged by role)
385 scope "/api/v1/pleroma/admin", Pleroma.Web.AdminAPI do
386 pipe_through(:require_privileged_role_users_read)
388 get("/users", UserController, :index)
389 get("/users/:nickname", UserController, :show)
392 # AdminAPI: admins and mods (staff) can perform these actions (if privileged by role)
393 scope "/api/v1/pleroma/admin", Pleroma.Web.AdminAPI do
394 pipe_through(:require_privileged_role_messages_delete)
396 put("/statuses/:id", StatusController, :update)
397 delete("/statuses/:id", StatusController, :delete)
399 delete("/chats/:id/messages/:message_id", ChatController, :delete_message)
402 # AdminAPI: admins and mods (staff) can perform these actions (if privileged by role)
403 scope "/api/v1/pleroma/admin", Pleroma.Web.AdminAPI do
404 pipe_through(:require_privileged_role_emoji_manage_emoji)
406 post("/reload_emoji", AdminAPIController, :reload_emoji)
409 # AdminAPI: admins and mods (staff) can perform these actions (if privileged by role)
410 scope "/api/v1/pleroma/admin", Pleroma.Web.AdminAPI do
411 pipe_through(:require_privileged_role_instances_delete)
413 delete("/instances/:instance", InstanceController, :delete)
416 # AdminAPI: admins and mods (staff) can perform these actions (if privileged by role)
417 scope "/api/v1/pleroma/admin", Pleroma.Web.AdminAPI do
418 pipe_through(:require_privileged_role_moderation_log_read)
420 get("/moderation_log", AdminAPIController, :list_log)
423 # AdminAPI: admins and mods (staff) can perform these actions (if privileged by role)
424 scope "/api/v1/pleroma/admin", Pleroma.Web.AdminAPI do
425 pipe_through(:require_privileged_role_statistics_read)
427 get("/stats", AdminAPIController, :stats)
430 scope "/api/v1/pleroma/emoji", Pleroma.Web.PleromaAPI do
432 pipe_through(:require_privileged_role_emoji_manage_emoji)
434 post("/", EmojiPackController, :create)
435 patch("/", EmojiPackController, :update)
436 delete("/", EmojiPackController, :delete)
442 get("/", EmojiPackController, :show)
447 pipe_through(:require_privileged_role_emoji_manage_emoji)
449 get("/import", EmojiPackController, :import_from_filesystem)
450 get("/remote", EmojiPackController, :remote)
451 post("/download", EmojiPackController, :download)
453 post("/files", EmojiFileController, :create)
454 patch("/files", EmojiFileController, :update)
455 delete("/files", EmojiFileController, :delete)
458 # Pack info / downloading
462 get("/", EmojiPackController, :index)
463 get("/archive", EmojiPackController, :archive)
467 scope "/", Pleroma.Web.TwitterAPI do
468 pipe_through(:pleroma_html)
470 post("/main/ostatus", UtilController, :remote_subscribe)
471 get("/main/ostatus", UtilController, :show_subscribe_form)
472 get("/ostatus_subscribe", RemoteFollowController, :follow)
473 post("/ostatus_subscribe", RemoteFollowController, :do_follow)
475 get("/authorize_interaction", RemoteFollowController, :authorize_interaction)
478 scope "/api/pleroma", Pleroma.Web.TwitterAPI do
479 pipe_through(:authenticated_api)
481 post("/change_email", UtilController, :change_email)
482 post("/change_password", UtilController, :change_password)
483 post("/delete_account", UtilController, :delete_account)
484 put("/notification_settings", UtilController, :update_notification_settings)
485 post("/disable_account", UtilController, :disable_account)
486 post("/move_account", UtilController, :move_account)
488 put("/aliases", UtilController, :add_alias)
489 get("/aliases", UtilController, :list_aliases)
490 delete("/aliases", UtilController, :delete_alias)
493 scope "/api/pleroma", Pleroma.Web.PleromaAPI do
494 pipe_through(:authenticated_api)
496 post("/mutes_import", UserImportController, :mutes)
497 post("/blocks_import", UserImportController, :blocks)
498 post("/follow_import", UserImportController, :follow)
500 get("/accounts/mfa", TwoFactorAuthenticationController, :settings)
501 get("/accounts/mfa/backup_codes", TwoFactorAuthenticationController, :backup_codes)
502 get("/accounts/mfa/setup/:method", TwoFactorAuthenticationController, :setup)
503 post("/accounts/mfa/confirm/:method", TwoFactorAuthenticationController, :confirm)
504 delete("/accounts/mfa/:method", TwoFactorAuthenticationController, :disable)
507 scope "/oauth", Pleroma.Web.OAuth do
508 # Note: use /api/v1/accounts/verify_credentials for userinfo of signed-in user
510 get("/registration_details", OAuthController, :registration_details)
512 post("/mfa/verify", MFAController, :verify, as: :mfa_verify)
513 get("/mfa", MFAController, :show)
518 get("/authorize", OAuthController, :authorize)
519 post("/authorize", OAuthController, :create_authorization)
523 pipe_through(:fetch_session)
525 post("/token", OAuthController, :token_exchange)
526 post("/revoke", OAuthController, :token_revoke)
527 post("/mfa/challenge", MFAController, :challenge)
531 pipe_through(:browser)
533 get("/prepare_request", OAuthController, :prepare_request)
534 get("/:provider", OAuthController, :request)
535 get("/:provider/callback", OAuthController, :callback)
536 post("/register", OAuthController, :register)
540 scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do
543 get("/apps", AppController, :index)
544 get("/statuses/:id/reactions/:emoji", EmojiReactionController, :index)
545 get("/statuses/:id/reactions", EmojiReactionController, :index)
548 scope "/api/v0/pleroma", Pleroma.Web.PleromaAPI do
549 pipe_through(:authenticated_api)
550 get("/reports", ReportController, :index)
551 get("/reports/:id", ReportController, :show)
554 scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do
556 pipe_through(:authenticated_api)
558 post("/chats/by-account-id/:id", ChatController, :create)
559 get("/chats", ChatController, :index)
560 get("/chats/:id", ChatController, :show)
561 get("/chats/:id/messages", ChatController, :messages)
562 post("/chats/:id/messages", ChatController, :post_chat_message)
563 delete("/chats/:id/messages/:message_id", ChatController, :delete_message)
564 post("/chats/:id/read", ChatController, :mark_as_read)
565 post("/chats/:id/messages/:message_id/read", ChatController, :mark_message_as_read)
567 get("/conversations/:id/statuses", ConversationController, :statuses)
568 get("/conversations/:id", ConversationController, :show)
569 post("/conversations/read", ConversationController, :mark_as_read)
570 patch("/conversations/:id", ConversationController, :update)
572 put("/statuses/:id/reactions/:emoji", EmojiReactionController, :create)
573 delete("/statuses/:id/reactions/:emoji", EmojiReactionController, :delete)
574 post("/notifications/read", NotificationController, :mark_as_read)
576 get("/mascot", MascotController, :show)
577 put("/mascot", MascotController, :update)
579 post("/scrobble", ScrobbleController, :create)
581 get("/backups", BackupController, :index)
582 post("/backups", BackupController, :create)
584 get("/bookmark_folders", BookmarkFolderController, :index)
585 post("/bookmark_folders", BookmarkFolderController, :create)
586 patch("/bookmark_folders/:id", BookmarkFolderController, :update)
587 delete("/bookmark_folders/:id", BookmarkFolderController, :delete)
592 get("/accounts/:id/favourites", AccountController, :favourites)
593 get("/accounts/:id/endorsements", AccountController, :endorsements)
595 get("/statuses/:id/quotes", StatusController, :quotes)
599 pipe_through(:authenticated_api)
601 post("/accounts/:id/subscribe", AccountController, :subscribe)
602 post("/accounts/:id/unsubscribe", AccountController, :unsubscribe)
604 get("/birthdays", AccountController, :birthdays)
608 pipe_through(:authenticated_api)
610 get("/settings/:app", SettingsController, :show)
611 patch("/settings/:app", SettingsController, :update)
614 post("/accounts/confirmation_resend", AccountController, :confirmation_resend)
617 scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do
619 get("/accounts/:id/scrobbles", ScrobbleController, :index)
622 scope "/api/v2/pleroma", Pleroma.Web.PleromaAPI do
624 pipe_through(:authenticated_api)
625 get("/chats", ChatController, :index2)
629 scope "/api/v1", Pleroma.Web.MastodonAPI do
630 pipe_through(:authenticated_api)
632 get("/accounts/verify_credentials", AccountController, :verify_credentials)
633 patch("/accounts/update_credentials", AccountController, :update_credentials)
635 get("/accounts/relationships", AccountController, :relationships)
636 get("/accounts/:id/lists", AccountController, :lists)
637 get("/accounts/:id/identity_proofs", AccountController, :identity_proofs)
638 get("/endorsements", AccountController, :endorsements)
639 get("/blocks", AccountController, :blocks)
640 get("/mutes", AccountController, :mutes)
642 post("/follows", AccountController, :follow_by_uri)
643 post("/accounts/:id/follow", AccountController, :follow)
644 post("/accounts/:id/unfollow", AccountController, :unfollow)
645 post("/accounts/:id/block", AccountController, :block)
646 post("/accounts/:id/unblock", AccountController, :unblock)
647 post("/accounts/:id/mute", AccountController, :mute)
648 post("/accounts/:id/unmute", AccountController, :unmute)
649 post("/accounts/:id/note", AccountController, :note)
650 post("/accounts/:id/pin", AccountController, :endorse)
651 post("/accounts/:id/unpin", AccountController, :unendorse)
652 post("/accounts/:id/remove_from_followers", AccountController, :remove_from_followers)
654 get("/conversations", ConversationController, :index)
655 post("/conversations/:id/read", ConversationController, :mark_as_read)
656 delete("/conversations/:id", ConversationController, :delete)
658 get("/domain_blocks", DomainBlockController, :index)
659 post("/domain_blocks", DomainBlockController, :create)
660 delete("/domain_blocks", DomainBlockController, :delete)
662 get("/filters", FilterController, :index)
664 post("/filters", FilterController, :create)
665 get("/filters/:id", FilterController, :show)
666 put("/filters/:id", FilterController, :update)
667 delete("/filters/:id", FilterController, :delete)
669 get("/follow_requests", FollowRequestController, :index)
670 post("/follow_requests/:id/authorize", FollowRequestController, :authorize)
671 post("/follow_requests/:id/reject", FollowRequestController, :reject)
673 get("/lists", ListController, :index)
674 get("/lists/:id", ListController, :show)
675 get("/lists/:id/accounts", ListController, :list_accounts)
677 delete("/lists/:id", ListController, :delete)
678 post("/lists", ListController, :create)
679 put("/lists/:id", ListController, :update)
680 post("/lists/:id/accounts", ListController, :add_to_list)
681 delete("/lists/:id/accounts", ListController, :remove_from_list)
683 get("/markers", MarkerController, :index)
684 post("/markers", MarkerController, :upsert)
686 post("/media", MediaController, :create)
687 get("/media/:id", MediaController, :show)
688 put("/media/:id", MediaController, :update)
690 get("/notifications", NotificationController, :index)
691 get("/notifications/:id", NotificationController, :show)
693 post("/notifications/:id/dismiss", NotificationController, :dismiss)
694 post("/notifications/clear", NotificationController, :clear)
695 delete("/notifications/destroy_multiple", NotificationController, :destroy_multiple)
696 # Deprecated: was removed in Mastodon v3, use `/notifications/:id/dismiss` instead
697 post("/notifications/dismiss", NotificationController, :dismiss_via_body)
699 post("/polls/:id/votes", PollController, :vote)
701 post("/reports", ReportController, :create)
703 get("/scheduled_statuses", ScheduledActivityController, :index)
704 get("/scheduled_statuses/:id", ScheduledActivityController, :show)
706 put("/scheduled_statuses/:id", ScheduledActivityController, :update)
707 delete("/scheduled_statuses/:id", ScheduledActivityController, :delete)
709 # Unlike `GET /api/v1/accounts/:id/favourites`, demands authentication
710 get("/favourites", StatusController, :favourites)
711 get("/bookmarks", StatusController, :bookmarks)
713 post("/statuses", StatusController, :create)
714 put("/statuses/:id", StatusController, :update)
715 delete("/statuses/:id", StatusController, :delete)
716 post("/statuses/:id/reblog", StatusController, :reblog)
717 post("/statuses/:id/unreblog", StatusController, :unreblog)
718 post("/statuses/:id/favourite", StatusController, :favourite)
719 post("/statuses/:id/unfavourite", StatusController, :unfavourite)
720 post("/statuses/:id/pin", StatusController, :pin)
721 post("/statuses/:id/unpin", StatusController, :unpin)
722 post("/statuses/:id/bookmark", StatusController, :bookmark)
723 post("/statuses/:id/unbookmark", StatusController, :unbookmark)
724 post("/statuses/:id/mute", StatusController, :mute_conversation)
725 post("/statuses/:id/unmute", StatusController, :unmute_conversation)
727 post("/push/subscription", SubscriptionController, :create)
728 get("/push/subscription", SubscriptionController, :show)
729 put("/push/subscription", SubscriptionController, :update)
730 delete("/push/subscription", SubscriptionController, :delete)
732 get("/suggestions", SuggestionController, :index)
733 delete("/suggestions/:account_id", SuggestionController, :dismiss)
735 get("/timelines/home", TimelineController, :home)
736 get("/timelines/direct", TimelineController, :direct)
737 get("/timelines/list/:list_id", TimelineController, :list)
739 get("/announcements", AnnouncementController, :index)
740 post("/announcements/:id/dismiss", AnnouncementController, :mark_read)
743 scope "/api/v1", Pleroma.Web.MastodonAPI do
744 pipe_through(:app_api)
746 post("/apps", AppController, :create)
747 get("/apps/verify_credentials", AppController, :verify_credentials)
750 scope "/api/v1", Pleroma.Web.MastodonAPI do
753 get("/accounts/search", SearchController, :account_search)
754 get("/search", SearchController, :search)
756 get("/accounts/lookup", AccountController, :lookup)
758 get("/accounts/:id/statuses", AccountController, :statuses)
759 get("/accounts/:id/followers", AccountController, :followers)
760 get("/accounts/:id/following", AccountController, :following)
761 get("/accounts/:id", AccountController, :show)
763 post("/accounts", AccountController, :create)
765 get("/instance", InstanceController, :show)
766 get("/instance/peers", InstanceController, :peers)
768 get("/statuses", StatusController, :index)
769 get("/statuses/:id", StatusController, :show)
770 get("/statuses/:id/context", StatusController, :context)
771 get("/statuses/:id/favourited_by", StatusController, :favourited_by)
772 get("/statuses/:id/reblogged_by", StatusController, :reblogged_by)
773 get("/statuses/:id/history", StatusController, :show_history)
774 get("/statuses/:id/source", StatusController, :show_source)
776 get("/custom_emojis", CustomEmojiController, :index)
778 get("/trends", MastodonAPIController, :empty_array)
780 get("/timelines/public", TimelineController, :public)
781 get("/timelines/tag/:tag", TimelineController, :hashtag)
783 get("/polls/:id", PollController, :show)
785 get("/directory", DirectoryController, :index)
788 scope "/api/v2", Pleroma.Web.MastodonAPI do
791 get("/search", SearchController, :search2)
793 post("/media", MediaController, :create2)
795 get("/suggestions", SuggestionController, :index2)
797 get("/instance", InstanceController, :show2)
800 scope "/api", Pleroma.Web do
801 pipe_through(:config)
803 get("/pleroma/frontend_configurations", TwitterAPI.UtilController, :frontend_configurations)
806 scope "/api", Pleroma.Web do
810 "/account/confirm_email/:user_id/:token",
811 TwitterAPI.Controller,
818 pipe_through(:base_api)
820 get("/openapi", OpenApiSpex.Plug.RenderSpec, [])
823 scope "/api", Pleroma.Web, as: :authenticated_twitter_api do
824 pipe_through(:authenticated_api)
826 get("/oauth_tokens", TwitterAPI.Controller, :oauth_tokens)
827 delete("/oauth_tokens/:id", TwitterAPI.Controller, :revoke_token)
830 scope "/", Pleroma.Web do
831 # Note: html format is supported only if static FE is enabled
832 # Note: http signature is only considered for json requests (no auth for non-json requests)
833 pipe_through([:accepts_html_json, :http_signature, :static_fe])
835 get("/objects/:uuid", OStatus.OStatusController, :object)
836 get("/activities/:uuid", OStatus.OStatusController, :activity)
837 get("/notice/:id", OStatus.OStatusController, :notice)
839 # Mastodon compatibility routes
840 get("/users/:nickname/statuses/:id", OStatus.OStatusController, :object)
841 get("/users/:nickname/statuses/:id/activity", OStatus.OStatusController, :activity)
844 scope "/", Pleroma.Web do
845 # Note: html format is supported only if static FE is enabled
846 # Note: http signature is only considered for json requests (no auth for non-json requests)
847 pipe_through([:accepts_html_xml_json, :http_signature, :static_fe])
849 # Note: returns user _profile_ for json requests, redirects to user _feed_ for non-json ones
850 get("/users/:nickname", Feed.UserController, :feed_redirect, as: :user_feed)
853 scope "/", Pleroma.Web do
854 pipe_through([:accepts_html_xml])
856 get("/users/:nickname/feed", Feed.UserController, :feed, as: :user_feed)
859 scope "/", Pleroma.Web do
860 pipe_through(:accepts_html)
861 get("/notice/:id/embed_player", OStatus.OStatusController, :notice_player)
864 scope "/", Pleroma.Web do
865 pipe_through(:accepts_xml_rss_atom)
866 get("/tags/:tag", Feed.TagController, :feed, as: :tag_feed)
869 scope "/", Pleroma.Web do
870 pipe_through(:browser)
871 get("/mailer/unsubscribe/:token", Mailer.SubscriptionController, :unsubscribe)
874 pipeline :ap_service_actor do
875 plug(:accepts, ["activity+json", "json"])
878 # Server to Server (S2S) AP interactions
879 pipeline :activitypub do
880 plug(:ap_service_actor)
881 plug(:http_signature)
884 # Client to Server (C2S) AP interactions
885 pipeline :activitypub_client do
886 plug(:ap_service_actor)
892 scope "/", Pleroma.Web.ActivityPub do
893 pipe_through([:activitypub_client])
895 get("/api/ap/whoami", ActivityPubController, :whoami)
896 get("/users/:nickname/inbox", ActivityPubController, :read_inbox)
898 get("/users/:nickname/outbox", ActivityPubController, :outbox)
899 post("/users/:nickname/outbox", ActivityPubController, :update_outbox)
900 post("/api/ap/upload_media", ActivityPubController, :upload_media)
902 # The following two are S2S as well, see `ActivityPub.fetch_follow_information_for_user/1`:
903 get("/users/:nickname/followers", ActivityPubController, :followers)
904 get("/users/:nickname/following", ActivityPubController, :following)
905 get("/users/:nickname/collections/featured", ActivityPubController, :pinned)
908 scope "/", Pleroma.Web.ActivityPub do
909 pipe_through(:activitypub)
910 post("/inbox", ActivityPubController, :inbox)
911 post("/users/:nickname/inbox", ActivityPubController, :inbox)
914 scope "/relay", Pleroma.Web.ActivityPub do
915 pipe_through(:ap_service_actor)
917 get("/", ActivityPubController, :relay)
920 pipe_through(:http_signature)
921 post("/inbox", ActivityPubController, :inbox)
924 get("/following", ActivityPubController, :relay_following)
925 get("/followers", ActivityPubController, :relay_followers)
928 scope "/internal/fetch", Pleroma.Web.ActivityPub do
929 pipe_through(:ap_service_actor)
931 get("/", ActivityPubController, :internal_fetch)
932 post("/inbox", ActivityPubController, :inbox)
935 scope "/.well-known", Pleroma.Web do
936 pipe_through(:well_known)
938 get("/host-meta", WebFinger.WebFingerController, :host_meta)
939 get("/webfinger", WebFinger.WebFingerController, :webfinger)
940 get("/nodeinfo", Nodeinfo.NodeinfoController, :schemas)
943 scope "/nodeinfo", Pleroma.Web do
944 get("/:version", Nodeinfo.NodeinfoController, :nodeinfo)
947 scope "/", Pleroma.Web do
950 get("/manifest.json", ManifestController, :show)
953 scope "/", Pleroma.Web do
954 pipe_through(:pleroma_html)
956 post("/auth/password", TwitterAPI.PasswordController, :request)
959 scope "/proxy/", Pleroma.Web do
960 get("/preview/:sig/:url", MediaProxy.MediaProxyController, :preview)
961 get("/preview/:sig/:url/:filename", MediaProxy.MediaProxyController, :preview)
962 get("/:sig/:url", MediaProxy.MediaProxyController, :remote)
963 get("/:sig/:url/:filename", MediaProxy.MediaProxyController, :remote)
966 if Pleroma.Config.get(:env) == :dev do
968 pipe_through([:mailbox_preview])
970 forward("/mailbox", Plug.Swoosh.MailboxPreview, base_path: "/dev/mailbox")
975 pipe_through([:pleroma_html, :authenticate, :require_admin])
976 live_dashboard("/phoenix/live_dashboard")
979 # Test-only routes needed to test action dispatching and plug chain execution
980 if Pleroma.Config.get(:env) == :test do
983 :fallback_oauth_check,
985 :fallback_oauth_skip_publicity_check,
986 :skip_oauth_skip_publicity_check,
987 :missing_oauth_check_definition
990 scope "/test/api", Pleroma.Tests do
993 for action <- @test_actions do
994 get("/#{action}", AuthTestController, action)
998 scope "/test/authenticated_api", Pleroma.Tests do
999 pipe_through(:authenticated_api)
1001 for action <- @test_actions do
1002 get("/#{action}", AuthTestController, action)
1007 scope "/", Pleroma.Web.MongooseIM do
1008 get("/user_exists", MongooseIMController, :user_exists)
1009 get("/check_password", MongooseIMController, :check_password)
1012 scope "/", Pleroma.Web.Fallback do
1013 get("/registration/:token", RedirectController, :registration_page)
1014 get("/:maybe_nickname_or_id", RedirectController, :redirector_with_meta)
1015 match(:*, "/api/pleroma/*path", LegacyPleromaApiRerouterPlug, [])
1016 get("/api/*path", RedirectController, :api_not_implemented)
1017 get("/*path", RedirectController, :redirector_with_preload)
1019 options("/*path", RedirectController, :empty)
1022 def get_api_routes do
1023 Phoenix.Router.routes(__MODULE__)
1024 |> Enum.reject(fn r -> r.plug == Pleroma.Web.Fallback.RedirectController end)
1027 |> String.split("/", trim: true)