1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.Router do
6 use Pleroma.Web, :router
9 plug(:accepts, ["html"])
15 plug(Pleroma.Plugs.OAuthPlug)
19 plug(:accepts, ["json"])
21 plug(Pleroma.Plugs.OAuthPlug)
22 plug(Pleroma.Plugs.BasicAuthDecoderPlug)
23 plug(Pleroma.Plugs.UserFetcherPlug)
24 plug(Pleroma.Plugs.SessionAuthenticationPlug)
25 plug(Pleroma.Plugs.LegacyAuthenticationPlug)
26 plug(Pleroma.Plugs.AuthenticationPlug)
27 plug(Pleroma.Plugs.UserEnabledPlug)
28 plug(Pleroma.Plugs.SetUserSessionIdPlug)
29 plug(Pleroma.Plugs.EnsureUserKeyPlug)
30 plug(Pleroma.Plugs.IdempotencyPlug)
33 pipeline :authenticated_api do
34 plug(:accepts, ["json"])
36 plug(Pleroma.Plugs.OAuthPlug)
37 plug(Pleroma.Plugs.BasicAuthDecoderPlug)
38 plug(Pleroma.Plugs.UserFetcherPlug)
39 plug(Pleroma.Plugs.SessionAuthenticationPlug)
40 plug(Pleroma.Plugs.LegacyAuthenticationPlug)
41 plug(Pleroma.Plugs.AuthenticationPlug)
42 plug(Pleroma.Plugs.UserEnabledPlug)
43 plug(Pleroma.Plugs.SetUserSessionIdPlug)
44 plug(Pleroma.Plugs.EnsureAuthenticatedPlug)
45 plug(Pleroma.Plugs.IdempotencyPlug)
48 pipeline :admin_api do
49 plug(:accepts, ["json"])
51 plug(Pleroma.Plugs.OAuthPlug)
52 plug(Pleroma.Plugs.BasicAuthDecoderPlug)
53 plug(Pleroma.Plugs.UserFetcherPlug)
54 plug(Pleroma.Plugs.SessionAuthenticationPlug)
55 plug(Pleroma.Plugs.LegacyAuthenticationPlug)
56 plug(Pleroma.Plugs.AuthenticationPlug)
57 plug(Pleroma.Plugs.AdminSecretAuthenticationPlug)
58 plug(Pleroma.Plugs.UserEnabledPlug)
59 plug(Pleroma.Plugs.SetUserSessionIdPlug)
60 plug(Pleroma.Plugs.EnsureAuthenticatedPlug)
61 plug(Pleroma.Plugs.UserIsAdminPlug)
62 plug(Pleroma.Plugs.IdempotencyPlug)
65 pipeline :mastodon_html do
66 plug(:accepts, ["html"])
68 plug(Pleroma.Plugs.OAuthPlug)
69 plug(Pleroma.Plugs.BasicAuthDecoderPlug)
70 plug(Pleroma.Plugs.UserFetcherPlug)
71 plug(Pleroma.Plugs.SessionAuthenticationPlug)
72 plug(Pleroma.Plugs.LegacyAuthenticationPlug)
73 plug(Pleroma.Plugs.AuthenticationPlug)
74 plug(Pleroma.Plugs.UserEnabledPlug)
75 plug(Pleroma.Plugs.SetUserSessionIdPlug)
76 plug(Pleroma.Plugs.EnsureUserKeyPlug)
79 pipeline :pleroma_html do
80 plug(:accepts, ["html"])
82 plug(Pleroma.Plugs.OAuthPlug)
83 plug(Pleroma.Plugs.BasicAuthDecoderPlug)
84 plug(Pleroma.Plugs.UserFetcherPlug)
85 plug(Pleroma.Plugs.SessionAuthenticationPlug)
86 plug(Pleroma.Plugs.AuthenticationPlug)
87 plug(Pleroma.Plugs.EnsureUserKeyPlug)
90 pipeline :oauth_read_or_public do
91 plug(Pleroma.Plugs.OAuthScopesPlug, %{
93 fallback: :proceed_unauthenticated
96 plug(Pleroma.Plugs.EnsurePublicOrAuthenticatedPlug)
99 pipeline :oauth_read do
100 plug(Pleroma.Plugs.OAuthScopesPlug, %{scopes: ["read"]})
103 pipeline :oauth_write do
104 plug(Pleroma.Plugs.OAuthScopesPlug, %{scopes: ["write"]})
107 pipeline :oauth_follow do
108 plug(Pleroma.Plugs.OAuthScopesPlug, %{scopes: ["follow"]})
111 pipeline :oauth_push do
112 plug(Pleroma.Plugs.OAuthScopesPlug, %{scopes: ["push"]})
115 pipeline :well_known do
116 plug(:accepts, ["json", "jrd+json", "xml", "xrd+xml"])
120 plug(:accepts, ["json", "xml"])
123 pipeline :pleroma_api do
124 plug(:accepts, ["html", "json"])
127 pipeline :mailbox_preview do
128 plug(:accepts, ["html"])
130 plug(:put_secure_browser_headers, %{
131 "content-security-policy" =>
132 "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline' 'unsafe-eval'"
136 scope "/api/pleroma", Pleroma.Web.TwitterAPI do
137 pipe_through(:pleroma_api)
139 get("/password_reset/:token", PasswordController, :reset, as: :reset_password)
140 post("/password_reset", PasswordController, :do_reset, as: :reset_password)
141 get("/emoji", UtilController, :emoji)
142 get("/captcha", UtilController, :captcha)
143 get("/healthcheck", UtilController, :healthcheck)
146 scope "/api/pleroma", Pleroma.Web do
147 pipe_through(:pleroma_api)
148 post("/uploader_callback/:upload_path", UploaderController, :callback)
151 scope "/api/pleroma/admin", Pleroma.Web.AdminAPI do
152 pipe_through([:admin_api, :oauth_write])
154 post("/users/follow", AdminAPIController, :user_follow)
155 post("/users/unfollow", AdminAPIController, :user_unfollow)
157 delete("/users", AdminAPIController, :user_delete)
158 post("/users", AdminAPIController, :user_create)
159 patch("/users/:nickname/toggle_activation", AdminAPIController, :user_toggle_activation)
160 put("/users/tag", AdminAPIController, :tag_users)
161 delete("/users/tag", AdminAPIController, :untag_users)
163 get("/users/:nickname/permission_group", AdminAPIController, :right_get)
164 get("/users/:nickname/permission_group/:permission_group", AdminAPIController, :right_get)
165 post("/users/:nickname/permission_group/:permission_group", AdminAPIController, :right_add)
168 "/users/:nickname/permission_group/:permission_group",
173 put("/users/:nickname/activation_status", AdminAPIController, :set_activation_status)
175 post("/relay", AdminAPIController, :relay_follow)
176 delete("/relay", AdminAPIController, :relay_unfollow)
178 get("/users/invite_token", AdminAPIController, :get_invite_token)
179 get("/users/invites", AdminAPIController, :invites)
180 post("/users/revoke_invite", AdminAPIController, :revoke_invite)
181 post("/users/email_invite", AdminAPIController, :email_invite)
183 get("/users/:nickname/password_reset", AdminAPIController, :get_password_reset)
185 get("/users", AdminAPIController, :list_users)
186 get("/users/:nickname", AdminAPIController, :user_show)
187 get("/users/:nickname/statuses", AdminAPIController, :list_user_statuses)
189 get("/reports", AdminAPIController, :list_reports)
190 get("/reports/:id", AdminAPIController, :report_show)
191 put("/reports/:id", AdminAPIController, :report_update_state)
192 post("/reports/:id/respond", AdminAPIController, :report_respond)
194 put("/statuses/:id", AdminAPIController, :status_update)
195 delete("/statuses/:id", AdminAPIController, :status_delete)
197 get("/config", AdminAPIController, :config_show)
198 post("/config", AdminAPIController, :config_update)
201 scope "/", Pleroma.Web.TwitterAPI do
202 pipe_through(:pleroma_html)
204 post("/main/ostatus", UtilController, :remote_subscribe)
205 get("/ostatus_subscribe", UtilController, :remote_follow)
208 pipe_through(:oauth_follow)
209 post("/ostatus_subscribe", UtilController, :do_remote_follow)
213 scope "/api/pleroma", Pleroma.Web.TwitterAPI do
214 pipe_through(:authenticated_api)
217 pipe_through(:oauth_write)
219 post("/change_password", UtilController, :change_password)
220 post("/delete_account", UtilController, :delete_account)
221 put("/notification_settings", UtilController, :update_notificaton_settings)
222 post("/disable_account", UtilController, :disable_account)
226 pipe_through(:oauth_follow)
228 post("/blocks_import", UtilController, :blocks_import)
229 post("/follow_import", UtilController, :follow_import)
233 pipe_through(:oauth_read)
235 post("/notifications/read", UtilController, :notifications_read)
239 scope "/oauth", Pleroma.Web.OAuth do
242 get("/authorize", OAuthController, :authorize)
245 post("/authorize", OAuthController, :create_authorization)
246 post("/token", OAuthController, :token_exchange)
247 post("/revoke", OAuthController, :token_revoke)
248 get("/registration_details", OAuthController, :registration_details)
251 pipe_through(:browser)
253 get("/prepare_request", OAuthController, :prepare_request)
254 get("/:provider", OAuthController, :request)
255 get("/:provider/callback", OAuthController, :callback)
256 post("/register", OAuthController, :register)
260 scope "/api/v1", Pleroma.Web.MastodonAPI do
261 pipe_through(:authenticated_api)
264 pipe_through(:oauth_read)
266 get("/accounts/verify_credentials", MastodonAPIController, :verify_credentials)
268 get("/accounts/relationships", MastodonAPIController, :relationships)
270 get("/accounts/:id/lists", MastodonAPIController, :account_lists)
271 get("/accounts/:id/identity_proofs", MastodonAPIController, :empty_array)
273 get("/follow_requests", MastodonAPIController, :follow_requests)
274 get("/blocks", MastodonAPIController, :blocks)
275 get("/mutes", MastodonAPIController, :mutes)
277 get("/timelines/home", MastodonAPIController, :home_timeline)
278 get("/timelines/direct", MastodonAPIController, :dm_timeline)
280 get("/favourites", MastodonAPIController, :favourites)
281 get("/bookmarks", MastodonAPIController, :bookmarks)
283 post("/notifications/clear", MastodonAPIController, :clear_notifications)
284 post("/notifications/dismiss", MastodonAPIController, :dismiss_notification)
285 get("/notifications", MastodonAPIController, :notifications)
286 get("/notifications/:id", MastodonAPIController, :get_notification)
287 delete("/notifications/destroy_multiple", MastodonAPIController, :destroy_multiple)
289 get("/scheduled_statuses", MastodonAPIController, :scheduled_statuses)
290 get("/scheduled_statuses/:id", MastodonAPIController, :show_scheduled_status)
292 get("/lists", MastodonAPIController, :get_lists)
293 get("/lists/:id", MastodonAPIController, :get_list)
294 get("/lists/:id/accounts", MastodonAPIController, :list_accounts)
296 get("/domain_blocks", MastodonAPIController, :domain_blocks)
298 get("/filters", MastodonAPIController, :get_filters)
300 get("/suggestions", MastodonAPIController, :suggestions)
302 get("/conversations", MastodonAPIController, :conversations)
303 post("/conversations/:id/read", MastodonAPIController, :conversation_read)
305 get("/endorsements", MastodonAPIController, :empty_array)
309 pipe_through(:oauth_write)
311 patch("/accounts/update_credentials", MastodonAPIController, :update_credentials)
313 post("/statuses", MastodonAPIController, :post_status)
314 delete("/statuses/:id", MastodonAPIController, :delete_status)
316 post("/statuses/:id/reblog", MastodonAPIController, :reblog_status)
317 post("/statuses/:id/unreblog", MastodonAPIController, :unreblog_status)
318 post("/statuses/:id/favourite", MastodonAPIController, :fav_status)
319 post("/statuses/:id/unfavourite", MastodonAPIController, :unfav_status)
320 post("/statuses/:id/pin", MastodonAPIController, :pin_status)
321 post("/statuses/:id/unpin", MastodonAPIController, :unpin_status)
322 post("/statuses/:id/bookmark", MastodonAPIController, :bookmark_status)
323 post("/statuses/:id/unbookmark", MastodonAPIController, :unbookmark_status)
324 post("/statuses/:id/mute", MastodonAPIController, :mute_conversation)
325 post("/statuses/:id/unmute", MastodonAPIController, :unmute_conversation)
327 put("/scheduled_statuses/:id", MastodonAPIController, :update_scheduled_status)
328 delete("/scheduled_statuses/:id", MastodonAPIController, :delete_scheduled_status)
330 post("/polls/:id/votes", MastodonAPIController, :poll_vote)
332 post("/media", MastodonAPIController, :upload)
333 put("/media/:id", MastodonAPIController, :update_media)
335 delete("/lists/:id", MastodonAPIController, :delete_list)
336 post("/lists", MastodonAPIController, :create_list)
337 put("/lists/:id", MastodonAPIController, :rename_list)
339 post("/lists/:id/accounts", MastodonAPIController, :add_to_list)
340 delete("/lists/:id/accounts", MastodonAPIController, :remove_from_list)
342 post("/filters", MastodonAPIController, :create_filter)
343 get("/filters/:id", MastodonAPIController, :get_filter)
344 put("/filters/:id", MastodonAPIController, :update_filter)
345 delete("/filters/:id", MastodonAPIController, :delete_filter)
347 patch("/pleroma/accounts/update_avatar", MastodonAPIController, :update_avatar)
348 patch("/pleroma/accounts/update_banner", MastodonAPIController, :update_banner)
349 patch("/pleroma/accounts/update_background", MastodonAPIController, :update_background)
351 get("/pleroma/mascot", MastodonAPIController, :get_mascot)
352 put("/pleroma/mascot", MastodonAPIController, :set_mascot)
354 post("/reports", MastodonAPIController, :reports)
358 pipe_through(:oauth_follow)
360 post("/follows", MastodonAPIController, :follow)
361 post("/accounts/:id/follow", MastodonAPIController, :follow)
363 post("/accounts/:id/unfollow", MastodonAPIController, :unfollow)
364 post("/accounts/:id/block", MastodonAPIController, :block)
365 post("/accounts/:id/unblock", MastodonAPIController, :unblock)
366 post("/accounts/:id/mute", MastodonAPIController, :mute)
367 post("/accounts/:id/unmute", MastodonAPIController, :unmute)
369 post("/follow_requests/:id/authorize", MastodonAPIController, :authorize_follow_request)
370 post("/follow_requests/:id/reject", MastodonAPIController, :reject_follow_request)
372 post("/domain_blocks", MastodonAPIController, :block_domain)
373 delete("/domain_blocks", MastodonAPIController, :unblock_domain)
375 post("/pleroma/accounts/:id/subscribe", MastodonAPIController, :subscribe)
376 post("/pleroma/accounts/:id/unsubscribe", MastodonAPIController, :unsubscribe)
380 pipe_through(:oauth_push)
382 post("/push/subscription", SubscriptionController, :create)
383 get("/push/subscription", SubscriptionController, :get)
384 put("/push/subscription", SubscriptionController, :update)
385 delete("/push/subscription", SubscriptionController, :delete)
389 scope "/api/web", Pleroma.Web.MastodonAPI do
390 pipe_through([:authenticated_api, :oauth_write])
392 put("/settings", MastodonAPIController, :put_settings)
395 scope "/api/v1", Pleroma.Web.MastodonAPI do
398 post("/accounts", MastodonAPIController, :account_register)
400 get("/instance", MastodonAPIController, :masto_instance)
401 get("/instance/peers", MastodonAPIController, :peers)
402 post("/apps", MastodonAPIController, :create_app)
403 get("/apps/verify_credentials", MastodonAPIController, :verify_app_credentials)
404 get("/custom_emojis", MastodonAPIController, :custom_emojis)
406 get("/statuses/:id/card", MastodonAPIController, :status_card)
408 get("/statuses/:id/favourited_by", MastodonAPIController, :favourited_by)
409 get("/statuses/:id/reblogged_by", MastodonAPIController, :reblogged_by)
411 get("/trends", MastodonAPIController, :empty_array)
413 get("/accounts/search", SearchController, :account_search)
416 pipe_through(:oauth_read_or_public)
418 get("/timelines/public", MastodonAPIController, :public_timeline)
419 get("/timelines/tag/:tag", MastodonAPIController, :hashtag_timeline)
420 get("/timelines/list/:list_id", MastodonAPIController, :list_timeline)
422 get("/statuses/:id", MastodonAPIController, :get_status)
423 get("/statuses/:id/context", MastodonAPIController, :get_context)
425 get("/polls/:id", MastodonAPIController, :get_poll)
427 get("/accounts/:id/statuses", MastodonAPIController, :user_statuses)
428 get("/accounts/:id/followers", MastodonAPIController, :followers)
429 get("/accounts/:id/following", MastodonAPIController, :following)
430 get("/accounts/:id", MastodonAPIController, :user)
432 get("/search", SearchController, :search)
434 get("/pleroma/accounts/:id/favourites", MastodonAPIController, :user_favourites)
438 scope "/api/v2", Pleroma.Web.MastodonAPI do
439 pipe_through([:api, :oauth_read_or_public])
440 get("/search", SearchController, :search2)
443 scope "/api", Pleroma.Web do
444 pipe_through(:config)
446 get("/help/test", TwitterAPI.UtilController, :help_test)
447 post("/help/test", TwitterAPI.UtilController, :help_test)
448 get("/statusnet/config", TwitterAPI.UtilController, :config)
449 get("/statusnet/version", TwitterAPI.UtilController, :version)
450 get("/pleroma/frontend_configurations", TwitterAPI.UtilController, :frontend_configurations)
453 scope "/api", Pleroma.Web do
456 post("/account/register", TwitterAPI.Controller, :register)
457 post("/account/password_reset", TwitterAPI.Controller, :password_reset)
459 post("/account/resend_confirmation_email", TwitterAPI.Controller, :resend_confirmation_email)
462 "/account/confirm_email/:user_id/:token",
463 TwitterAPI.Controller,
469 pipe_through(:oauth_read_or_public)
471 get("/statuses/user_timeline", TwitterAPI.Controller, :user_timeline)
472 get("/qvitter/statuses/user_timeline", TwitterAPI.Controller, :user_timeline)
473 get("/users/show", TwitterAPI.Controller, :show_user)
475 get("/statuses/followers", TwitterAPI.Controller, :followers)
476 get("/statuses/friends", TwitterAPI.Controller, :friends)
477 get("/statuses/blocks", TwitterAPI.Controller, :blocks)
478 get("/statuses/show/:id", TwitterAPI.Controller, :fetch_status)
479 get("/statusnet/conversation/:id", TwitterAPI.Controller, :fetch_conversation)
481 get("/search", TwitterAPI.Controller, :search)
482 get("/statusnet/tags/timeline/:tag", TwitterAPI.Controller, :public_and_external_timeline)
486 scope "/api", Pleroma.Web do
487 pipe_through([:api, :oauth_read_or_public])
489 get("/statuses/public_timeline", TwitterAPI.Controller, :public_timeline)
492 "/statuses/public_and_external_timeline",
493 TwitterAPI.Controller,
494 :public_and_external_timeline
497 get("/statuses/networkpublic_timeline", TwitterAPI.Controller, :public_and_external_timeline)
500 scope "/api", Pleroma.Web, as: :twitter_api_search do
501 pipe_through([:api, :oauth_read_or_public])
502 get("/pleroma/search_user", TwitterAPI.Controller, :search_user)
505 scope "/api", Pleroma.Web, as: :authenticated_twitter_api do
506 pipe_through(:authenticated_api)
508 get("/oauth_tokens", TwitterAPI.Controller, :oauth_tokens)
509 delete("/oauth_tokens/:id", TwitterAPI.Controller, :revoke_token)
512 pipe_through(:oauth_read)
514 get("/account/verify_credentials", TwitterAPI.Controller, :verify_credentials)
515 post("/account/verify_credentials", TwitterAPI.Controller, :verify_credentials)
517 get("/statuses/home_timeline", TwitterAPI.Controller, :friends_timeline)
518 get("/statuses/friends_timeline", TwitterAPI.Controller, :friends_timeline)
519 get("/statuses/mentions", TwitterAPI.Controller, :mentions_timeline)
520 get("/statuses/mentions_timeline", TwitterAPI.Controller, :mentions_timeline)
521 get("/statuses/dm_timeline", TwitterAPI.Controller, :dm_timeline)
522 get("/qvitter/statuses/notifications", TwitterAPI.Controller, :notifications)
524 get("/pleroma/friend_requests", TwitterAPI.Controller, :friend_requests)
526 get("/friends/ids", TwitterAPI.Controller, :friends_ids)
527 get("/friendships/no_retweets/ids", TwitterAPI.Controller, :empty_array)
529 get("/mutes/users/ids", TwitterAPI.Controller, :empty_array)
530 get("/qvitter/mutes", TwitterAPI.Controller, :raw_empty_array)
532 get("/externalprofile/show", TwitterAPI.Controller, :external_profile)
534 post("/qvitter/statuses/notifications/read", TwitterAPI.Controller, :notifications_read)
538 pipe_through(:oauth_write)
540 post("/account/update_profile", TwitterAPI.Controller, :update_profile)
541 post("/account/update_profile_banner", TwitterAPI.Controller, :update_banner)
542 post("/qvitter/update_background_image", TwitterAPI.Controller, :update_background)
544 post("/statuses/update", TwitterAPI.Controller, :status_update)
545 post("/statuses/retweet/:id", TwitterAPI.Controller, :retweet)
546 post("/statuses/unretweet/:id", TwitterAPI.Controller, :unretweet)
547 post("/statuses/destroy/:id", TwitterAPI.Controller, :delete_post)
549 post("/statuses/pin/:id", TwitterAPI.Controller, :pin)
550 post("/statuses/unpin/:id", TwitterAPI.Controller, :unpin)
552 post("/statusnet/media/upload", TwitterAPI.Controller, :upload)
553 post("/media/upload", TwitterAPI.Controller, :upload_json)
554 post("/media/metadata/create", TwitterAPI.Controller, :update_media)
556 post("/favorites/create/:id", TwitterAPI.Controller, :favorite)
557 post("/favorites/create", TwitterAPI.Controller, :favorite)
558 post("/favorites/destroy/:id", TwitterAPI.Controller, :unfavorite)
560 post("/qvitter/update_avatar", TwitterAPI.Controller, :update_avatar)
564 pipe_through(:oauth_follow)
566 post("/pleroma/friendships/approve", TwitterAPI.Controller, :approve_friend_request)
567 post("/pleroma/friendships/deny", TwitterAPI.Controller, :deny_friend_request)
569 post("/friendships/create", TwitterAPI.Controller, :follow)
570 post("/friendships/destroy", TwitterAPI.Controller, :unfollow)
572 post("/blocks/create", TwitterAPI.Controller, :block)
573 post("/blocks/destroy", TwitterAPI.Controller, :unblock)
577 pipeline :ap_service_actor do
578 plug(:accepts, ["activity+json", "json"])
582 plug(:accepts, ["html", "xml", "atom", "activity+json", "json"])
586 plug(:accepts, ["json", "xml"])
589 scope "/", Pleroma.Web do
590 pipe_through(:ostatus)
592 get("/objects/:uuid", OStatus.OStatusController, :object)
593 get("/activities/:uuid", OStatus.OStatusController, :activity)
594 get("/notice/:id", OStatus.OStatusController, :notice)
595 get("/notice/:id/embed_player", OStatus.OStatusController, :notice_player)
596 get("/users/:nickname/feed", OStatus.OStatusController, :feed)
597 get("/users/:nickname", OStatus.OStatusController, :feed_redirect)
599 post("/users/:nickname/salmon", OStatus.OStatusController, :salmon_incoming)
600 post("/push/hub/:nickname", Websub.WebsubController, :websub_subscription_request)
601 get("/push/subscriptions/:id", Websub.WebsubController, :websub_subscription_confirmation)
602 post("/push/subscriptions/:id", Websub.WebsubController, :websub_incoming)
605 pipeline :activitypub do
606 plug(:accepts, ["activity+json", "json"])
607 plug(Pleroma.Web.Plugs.HTTPSignaturePlug)
608 plug(Pleroma.Web.Plugs.MappedSignatureToIdentityPlug)
611 scope "/", Pleroma.Web.ActivityPub do
612 # XXX: not really ostatus
613 pipe_through(:ostatus)
615 get("/users/:nickname/outbox", ActivityPubController, :outbox)
616 get("/objects/:uuid/likes", ActivityPubController, :object_likes)
619 pipeline :activitypub_client do
620 plug(:accepts, ["activity+json", "json"])
622 plug(Pleroma.Plugs.OAuthPlug)
623 plug(Pleroma.Plugs.BasicAuthDecoderPlug)
624 plug(Pleroma.Plugs.UserFetcherPlug)
625 plug(Pleroma.Plugs.SessionAuthenticationPlug)
626 plug(Pleroma.Plugs.LegacyAuthenticationPlug)
627 plug(Pleroma.Plugs.AuthenticationPlug)
628 plug(Pleroma.Plugs.UserEnabledPlug)
629 plug(Pleroma.Plugs.SetUserSessionIdPlug)
630 plug(Pleroma.Plugs.EnsureUserKeyPlug)
633 scope "/", Pleroma.Web.ActivityPub do
634 pipe_through([:activitypub_client])
637 pipe_through(:oauth_read)
638 get("/api/ap/whoami", ActivityPubController, :whoami)
639 get("/users/:nickname/inbox", ActivityPubController, :read_inbox)
643 pipe_through(:oauth_write)
644 post("/users/:nickname/outbox", ActivityPubController, :update_outbox)
648 pipe_through(:oauth_read_or_public)
649 get("/users/:nickname/followers", ActivityPubController, :followers)
650 get("/users/:nickname/following", ActivityPubController, :following)
654 scope "/", Pleroma.Web.ActivityPub do
655 pipe_through(:activitypub)
656 post("/inbox", ActivityPubController, :inbox)
657 post("/users/:nickname/inbox", ActivityPubController, :inbox)
660 scope "/relay", Pleroma.Web.ActivityPub do
661 pipe_through(:ap_service_actor)
663 get("/", ActivityPubController, :relay)
664 post("/inbox", ActivityPubController, :inbox)
667 scope "/internal/fetch", Pleroma.Web.ActivityPub do
668 pipe_through(:ap_service_actor)
670 get("/", ActivityPubController, :internal_fetch)
671 post("/inbox", ActivityPubController, :inbox)
674 scope "/.well-known", Pleroma.Web do
675 pipe_through(:well_known)
677 get("/host-meta", WebFinger.WebFingerController, :host_meta)
678 get("/webfinger", WebFinger.WebFingerController, :webfinger)
679 get("/nodeinfo", Nodeinfo.NodeinfoController, :schemas)
682 scope "/nodeinfo", Pleroma.Web do
683 get("/:version", Nodeinfo.NodeinfoController, :nodeinfo)
686 scope "/", Pleroma.Web.MastodonAPI do
687 pipe_through(:mastodon_html)
689 get("/web/login", MastodonAPIController, :login)
690 delete("/auth/sign_out", MastodonAPIController, :logout)
692 post("/auth/password", MastodonAPIController, :password_reset)
695 pipe_through(:oauth_read_or_public)
696 get("/web/*path", MastodonAPIController, :index)
700 pipeline :remote_media do
703 scope "/proxy/", Pleroma.Web.MediaProxy do
704 pipe_through(:remote_media)
706 get("/:sig/:url", MediaProxyController, :remote)
707 get("/:sig/:url/:filename", MediaProxyController, :remote)
710 if Pleroma.Config.get(:env) == :dev do
712 pipe_through([:mailbox_preview])
714 forward("/mailbox", Plug.Swoosh.MailboxPreview, base_path: "/dev/mailbox")
718 scope "/", Pleroma.Web.MongooseIM do
719 get("/user_exists", MongooseIMController, :user_exists)
720 get("/check_password", MongooseIMController, :check_password)
723 scope "/", Fallback do
724 get("/registration/:token", RedirectController, :registration_page)
725 get("/:maybe_nickname_or_id", RedirectController, :redirector_with_meta)
726 get("/api*path", RedirectController, :api_not_implemented)
727 get("/*path", RedirectController, :redirector)
729 options("/*path", RedirectController, :empty)
733 defmodule Fallback.RedirectController do
734 use Pleroma.Web, :controller
737 alias Pleroma.Web.Metadata
739 def api_not_implemented(conn, _params) do
742 |> json(%{error: "Not implemented"})
745 def redirector(conn, _params, code \\ 200) do
747 |> put_resp_content_type("text/html")
748 |> send_file(code, index_file_path())
751 def redirector_with_meta(conn, %{"maybe_nickname_or_id" => maybe_nickname_or_id} = params) do
752 with %User{} = user <- User.get_cached_by_nickname_or_id(maybe_nickname_or_id) do
753 redirector_with_meta(conn, %{user: user})
756 redirector(conn, params)
760 def redirector_with_meta(conn, params) do
761 {:ok, index_content} = File.read(index_file_path())
765 Metadata.build_tags(params)
769 "Metadata rendering for #{conn.request_path} failed.\n" <>
770 Exception.format(:error, e, __STACKTRACE__)
776 response = String.replace(index_content, "<!--server-generated-meta-->", tags)
779 |> put_resp_content_type("text/html")
780 |> send_resp(200, response)
783 def index_file_path do
784 Pleroma.Plugs.InstanceStatic.file_path("index.html")
787 def registration_page(conn, params) do
788 redirector(conn, params)
791 def empty(conn, _params) do