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)
32 pipeline :authenticated_api do
33 plug(:accepts, ["json"])
35 plug(Pleroma.Plugs.OAuthPlug)
36 plug(Pleroma.Plugs.BasicAuthDecoderPlug)
37 plug(Pleroma.Plugs.UserFetcherPlug)
38 plug(Pleroma.Plugs.SessionAuthenticationPlug)
39 plug(Pleroma.Plugs.LegacyAuthenticationPlug)
40 plug(Pleroma.Plugs.AuthenticationPlug)
41 plug(Pleroma.Plugs.UserEnabledPlug)
42 plug(Pleroma.Plugs.SetUserSessionIdPlug)
43 plug(Pleroma.Plugs.EnsureAuthenticatedPlug)
46 pipeline :admin_api do
47 plug(:accepts, ["json"])
49 plug(Pleroma.Plugs.OAuthPlug)
50 plug(Pleroma.Plugs.BasicAuthDecoderPlug)
51 plug(Pleroma.Plugs.UserFetcherPlug)
52 plug(Pleroma.Plugs.SessionAuthenticationPlug)
53 plug(Pleroma.Plugs.LegacyAuthenticationPlug)
54 plug(Pleroma.Plugs.AuthenticationPlug)
55 plug(Pleroma.Plugs.AdminSecretAuthenticationPlug)
56 plug(Pleroma.Plugs.UserEnabledPlug)
57 plug(Pleroma.Plugs.SetUserSessionIdPlug)
58 plug(Pleroma.Plugs.EnsureAuthenticatedPlug)
59 plug(Pleroma.Plugs.UserIsAdminPlug)
62 pipeline :mastodon_html do
63 plug(:accepts, ["html"])
65 plug(Pleroma.Plugs.OAuthPlug)
66 plug(Pleroma.Plugs.BasicAuthDecoderPlug)
67 plug(Pleroma.Plugs.UserFetcherPlug)
68 plug(Pleroma.Plugs.SessionAuthenticationPlug)
69 plug(Pleroma.Plugs.LegacyAuthenticationPlug)
70 plug(Pleroma.Plugs.AuthenticationPlug)
71 plug(Pleroma.Plugs.UserEnabledPlug)
72 plug(Pleroma.Plugs.SetUserSessionIdPlug)
73 plug(Pleroma.Plugs.EnsureUserKeyPlug)
76 pipeline :pleroma_html do
77 plug(:accepts, ["html"])
79 plug(Pleroma.Plugs.OAuthPlug)
80 plug(Pleroma.Plugs.BasicAuthDecoderPlug)
81 plug(Pleroma.Plugs.UserFetcherPlug)
82 plug(Pleroma.Plugs.SessionAuthenticationPlug)
83 plug(Pleroma.Plugs.AuthenticationPlug)
84 plug(Pleroma.Plugs.EnsureUserKeyPlug)
87 pipeline :oauth_read_or_unauthenticated do
88 plug(Pleroma.Plugs.OAuthScopesPlug, %{
90 fallback: :proceed_unauthenticated
94 pipeline :oauth_read do
95 plug(Pleroma.Plugs.OAuthScopesPlug, %{scopes: ["read"]})
98 pipeline :oauth_write do
99 plug(Pleroma.Plugs.OAuthScopesPlug, %{scopes: ["write"]})
102 pipeline :oauth_follow do
103 plug(Pleroma.Plugs.OAuthScopesPlug, %{scopes: ["follow"]})
106 pipeline :oauth_push do
107 plug(Pleroma.Plugs.OAuthScopesPlug, %{scopes: ["push"]})
110 pipeline :well_known do
111 plug(:accepts, ["json", "jrd+json", "xml", "xrd+xml"])
115 plug(:accepts, ["json", "xml"])
118 pipeline :pleroma_api do
119 plug(:accepts, ["html", "json"])
122 pipeline :mailbox_preview do
123 plug(:accepts, ["html"])
125 plug(:put_secure_browser_headers, %{
126 "content-security-policy" =>
127 "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline' 'unsafe-eval'"
131 scope "/api/pleroma", Pleroma.Web.TwitterAPI do
132 pipe_through(:pleroma_api)
134 get("/password_reset/:token", UtilController, :show_password_reset)
135 post("/password_reset", UtilController, :password_reset)
136 get("/emoji", UtilController, :emoji)
137 get("/captcha", UtilController, :captcha)
138 get("/healthcheck", UtilController, :healthcheck)
141 scope "/api/pleroma", Pleroma.Web do
142 pipe_through(:pleroma_api)
143 post("/uploader_callback/:upload_path", UploaderController, :callback)
146 scope "/api/pleroma/admin", Pleroma.Web.AdminAPI do
147 pipe_through([:admin_api, :oauth_write])
149 post("/user/follow", AdminAPIController, :user_follow)
150 post("/user/unfollow", AdminAPIController, :user_unfollow)
152 get("/users", AdminAPIController, :list_users)
153 get("/users/:nickname", AdminAPIController, :user_show)
155 delete("/user", AdminAPIController, :user_delete)
156 patch("/users/:nickname/toggle_activation", AdminAPIController, :user_toggle_activation)
157 post("/user", AdminAPIController, :user_create)
158 put("/users/tag", AdminAPIController, :tag_users)
159 delete("/users/tag", AdminAPIController, :untag_users)
161 get("/permission_group/:nickname", AdminAPIController, :right_get)
162 get("/permission_group/:nickname/:permission_group", AdminAPIController, :right_get)
163 post("/permission_group/:nickname/:permission_group", AdminAPIController, :right_add)
164 delete("/permission_group/:nickname/:permission_group", AdminAPIController, :right_delete)
166 put("/activation_status/:nickname", AdminAPIController, :set_activation_status)
168 post("/relay", AdminAPIController, :relay_follow)
169 delete("/relay", AdminAPIController, :relay_unfollow)
171 get("/invite_token", AdminAPIController, :get_invite_token)
172 get("/invites", AdminAPIController, :invites)
173 post("/revoke_invite", AdminAPIController, :revoke_invite)
174 post("/email_invite", AdminAPIController, :email_invite)
176 get("/password_reset", AdminAPIController, :get_password_reset)
179 scope "/", Pleroma.Web.TwitterAPI do
180 pipe_through(:pleroma_html)
182 post("/main/ostatus", UtilController, :remote_subscribe)
183 get("/ostatus_subscribe", UtilController, :remote_follow)
186 pipe_through(:oauth_follow)
187 post("/ostatus_subscribe", UtilController, :do_remote_follow)
191 scope "/api/pleroma", Pleroma.Web.TwitterAPI do
192 pipe_through(:authenticated_api)
195 pipe_through(:oauth_write)
197 post("/change_password", UtilController, :change_password)
198 post("/delete_account", UtilController, :delete_account)
199 put("/notification_settings", UtilController, :update_notificaton_settings)
203 pipe_through(:oauth_follow)
205 post("/blocks_import", UtilController, :blocks_import)
206 post("/follow_import", UtilController, :follow_import)
210 pipe_through(:oauth_read)
212 post("/notifications/read", UtilController, :notifications_read)
216 scope "/oauth", Pleroma.Web.OAuth do
219 get("/authorize", OAuthController, :authorize)
222 post("/authorize", OAuthController, :create_authorization)
223 post("/token", OAuthController, :token_exchange)
224 post("/revoke", OAuthController, :token_revoke)
225 get("/registration_details", OAuthController, :registration_details)
228 pipe_through(:browser)
230 get("/prepare_request", OAuthController, :prepare_request)
231 get("/:provider", OAuthController, :request)
232 get("/:provider/callback", OAuthController, :callback)
233 post("/register", OAuthController, :register)
237 scope "/api/v1", Pleroma.Web.MastodonAPI do
238 pipe_through(:authenticated_api)
241 pipe_through(:oauth_read)
243 get("/accounts/verify_credentials", MastodonAPIController, :verify_credentials)
245 get("/accounts/relationships", MastodonAPIController, :relationships)
247 get("/accounts/:id/lists", MastodonAPIController, :account_lists)
248 get("/accounts/:id/identity_proofs", MastodonAPIController, :empty_array)
250 get("/follow_requests", MastodonAPIController, :follow_requests)
251 get("/blocks", MastodonAPIController, :blocks)
252 get("/mutes", MastodonAPIController, :mutes)
254 get("/timelines/home", MastodonAPIController, :home_timeline)
255 get("/timelines/direct", MastodonAPIController, :dm_timeline)
257 get("/favourites", MastodonAPIController, :favourites)
258 get("/bookmarks", MastodonAPIController, :bookmarks)
260 post("/notifications/clear", MastodonAPIController, :clear_notifications)
261 post("/notifications/dismiss", MastodonAPIController, :dismiss_notification)
262 get("/notifications", MastodonAPIController, :notifications)
263 get("/notifications/:id", MastodonAPIController, :get_notification)
264 delete("/notifications/destroy_multiple", MastodonAPIController, :destroy_multiple)
266 get("/scheduled_statuses", MastodonAPIController, :scheduled_statuses)
267 get("/scheduled_statuses/:id", MastodonAPIController, :show_scheduled_status)
269 get("/lists", MastodonAPIController, :get_lists)
270 get("/lists/:id", MastodonAPIController, :get_list)
271 get("/lists/:id/accounts", MastodonAPIController, :list_accounts)
273 get("/domain_blocks", MastodonAPIController, :domain_blocks)
275 get("/filters", MastodonAPIController, :get_filters)
277 get("/suggestions", MastodonAPIController, :suggestions)
279 get("/endorsements", MastodonAPIController, :empty_array)
281 get("/pleroma/flavour", MastodonAPIController, :get_flavour)
285 pipe_through(:oauth_write)
287 patch("/accounts/update_credentials", MastodonAPIController, :update_credentials)
289 post("/statuses", MastodonAPIController, :post_status)
290 delete("/statuses/:id", MastodonAPIController, :delete_status)
292 post("/statuses/:id/reblog", MastodonAPIController, :reblog_status)
293 post("/statuses/:id/unreblog", MastodonAPIController, :unreblog_status)
294 post("/statuses/:id/favourite", MastodonAPIController, :fav_status)
295 post("/statuses/:id/unfavourite", MastodonAPIController, :unfav_status)
296 post("/statuses/:id/pin", MastodonAPIController, :pin_status)
297 post("/statuses/:id/unpin", MastodonAPIController, :unpin_status)
298 post("/statuses/:id/bookmark", MastodonAPIController, :bookmark_status)
299 post("/statuses/:id/unbookmark", MastodonAPIController, :unbookmark_status)
300 post("/statuses/:id/mute", MastodonAPIController, :mute_conversation)
301 post("/statuses/:id/unmute", MastodonAPIController, :unmute_conversation)
303 put("/scheduled_statuses/:id", MastodonAPIController, :update_scheduled_status)
304 delete("/scheduled_statuses/:id", MastodonAPIController, :delete_scheduled_status)
306 post("/media", MastodonAPIController, :upload)
307 put("/media/:id", MastodonAPIController, :update_media)
309 delete("/lists/:id", MastodonAPIController, :delete_list)
310 post("/lists", MastodonAPIController, :create_list)
311 put("/lists/:id", MastodonAPIController, :rename_list)
313 post("/lists/:id/accounts", MastodonAPIController, :add_to_list)
314 delete("/lists/:id/accounts", MastodonAPIController, :remove_from_list)
316 post("/filters", MastodonAPIController, :create_filter)
317 get("/filters/:id", MastodonAPIController, :get_filter)
318 put("/filters/:id", MastodonAPIController, :update_filter)
319 delete("/filters/:id", MastodonAPIController, :delete_filter)
321 post("/pleroma/flavour/:flavour", MastodonAPIController, :set_flavour)
323 post("/reports", MastodonAPIController, :reports)
327 pipe_through(:oauth_follow)
329 post("/follows", MastodonAPIController, :follow)
330 post("/accounts/:id/follow", MastodonAPIController, :follow)
332 post("/accounts/:id/unfollow", MastodonAPIController, :unfollow)
333 post("/accounts/:id/block", MastodonAPIController, :block)
334 post("/accounts/:id/unblock", MastodonAPIController, :unblock)
335 post("/accounts/:id/mute", MastodonAPIController, :mute)
336 post("/accounts/:id/unmute", MastodonAPIController, :unmute)
338 post("/follow_requests/:id/authorize", MastodonAPIController, :authorize_follow_request)
339 post("/follow_requests/:id/reject", MastodonAPIController, :reject_follow_request)
341 post("/domain_blocks", MastodonAPIController, :block_domain)
342 delete("/domain_blocks", MastodonAPIController, :unblock_domain)
344 post("/pleroma/accounts/:id/subscribe", MastodonAPIController, :subscribe)
345 post("/pleroma/accounts/:id/unsubscribe", MastodonAPIController, :unsubscribe)
349 pipe_through(:oauth_push)
351 post("/push/subscription", SubscriptionController, :create)
352 get("/push/subscription", SubscriptionController, :get)
353 put("/push/subscription", SubscriptionController, :update)
354 delete("/push/subscription", SubscriptionController, :delete)
358 scope "/api/web", Pleroma.Web.MastodonAPI do
359 pipe_through([:authenticated_api, :oauth_write])
361 put("/settings", MastodonAPIController, :put_settings)
364 scope "/api/v1", Pleroma.Web.MastodonAPI do
367 get("/instance", MastodonAPIController, :masto_instance)
368 get("/instance/peers", MastodonAPIController, :peers)
369 post("/apps", MastodonAPIController, :create_app)
370 get("/apps/verify_credentials", MastodonAPIController, :verify_app_credentials)
371 get("/custom_emojis", MastodonAPIController, :custom_emojis)
373 get("/statuses/:id/card", MastodonAPIController, :status_card)
375 get("/statuses/:id/favourited_by", MastodonAPIController, :favourited_by)
376 get("/statuses/:id/reblogged_by", MastodonAPIController, :reblogged_by)
378 get("/trends", MastodonAPIController, :empty_array)
380 get("/accounts/search", MastodonAPIController, :account_search)
383 pipe_through(:oauth_read_or_unauthenticated)
385 get("/timelines/public", MastodonAPIController, :public_timeline)
386 get("/timelines/tag/:tag", MastodonAPIController, :hashtag_timeline)
387 get("/timelines/list/:list_id", MastodonAPIController, :list_timeline)
389 get("/statuses/:id", MastodonAPIController, :get_status)
390 get("/statuses/:id/context", MastodonAPIController, :get_context)
392 get("/accounts/:id/statuses", MastodonAPIController, :user_statuses)
393 get("/accounts/:id/followers", MastodonAPIController, :followers)
394 get("/accounts/:id/following", MastodonAPIController, :following)
395 get("/accounts/:id", MastodonAPIController, :user)
397 get("/search", MastodonAPIController, :search)
401 scope "/api/v2", Pleroma.Web.MastodonAPI do
402 pipe_through([:api, :oauth_read_or_unauthenticated])
403 get("/search", MastodonAPIController, :search2)
406 scope "/api", Pleroma.Web do
407 pipe_through(:config)
409 get("/help/test", TwitterAPI.UtilController, :help_test)
410 post("/help/test", TwitterAPI.UtilController, :help_test)
411 get("/statusnet/config", TwitterAPI.UtilController, :config)
412 get("/statusnet/version", TwitterAPI.UtilController, :version)
413 get("/pleroma/frontend_configurations", TwitterAPI.UtilController, :frontend_configurations)
416 scope "/api", Pleroma.Web do
419 post("/account/register", TwitterAPI.Controller, :register)
420 post("/account/password_reset", TwitterAPI.Controller, :password_reset)
422 post("/account/resend_confirmation_email", TwitterAPI.Controller, :resend_confirmation_email)
425 "/account/confirm_email/:user_id/:token",
426 TwitterAPI.Controller,
432 pipe_through(:oauth_read_or_unauthenticated)
434 get("/statuses/user_timeline", TwitterAPI.Controller, :user_timeline)
435 get("/qvitter/statuses/user_timeline", TwitterAPI.Controller, :user_timeline)
436 get("/users/show", TwitterAPI.Controller, :show_user)
438 get("/statuses/followers", TwitterAPI.Controller, :followers)
439 get("/statuses/friends", TwitterAPI.Controller, :friends)
440 get("/statuses/blocks", TwitterAPI.Controller, :blocks)
441 get("/statuses/show/:id", TwitterAPI.Controller, :fetch_status)
442 get("/statusnet/conversation/:id", TwitterAPI.Controller, :fetch_conversation)
444 get("/search", TwitterAPI.Controller, :search)
445 get("/statusnet/tags/timeline/:tag", TwitterAPI.Controller, :public_and_external_timeline)
449 scope "/api", Pleroma.Web do
450 pipe_through([:api, :oauth_read_or_unauthenticated])
452 get("/statuses/public_timeline", TwitterAPI.Controller, :public_timeline)
455 "/statuses/public_and_external_timeline",
456 TwitterAPI.Controller,
457 :public_and_external_timeline
460 get("/statuses/networkpublic_timeline", TwitterAPI.Controller, :public_and_external_timeline)
463 scope "/api", Pleroma.Web, as: :twitter_api_search do
464 pipe_through([:api, :oauth_read_or_unauthenticated])
465 get("/pleroma/search_user", TwitterAPI.Controller, :search_user)
468 scope "/api", Pleroma.Web, as: :authenticated_twitter_api do
469 pipe_through(:authenticated_api)
471 get("/oauth_tokens", TwitterAPI.Controller, :oauth_tokens)
472 delete("/oauth_tokens/:id", TwitterAPI.Controller, :revoke_token)
475 pipe_through(:oauth_read)
477 get("/account/verify_credentials", TwitterAPI.Controller, :verify_credentials)
478 post("/account/verify_credentials", TwitterAPI.Controller, :verify_credentials)
480 get("/statuses/home_timeline", TwitterAPI.Controller, :friends_timeline)
481 get("/statuses/friends_timeline", TwitterAPI.Controller, :friends_timeline)
482 get("/statuses/mentions", TwitterAPI.Controller, :mentions_timeline)
483 get("/statuses/mentions_timeline", TwitterAPI.Controller, :mentions_timeline)
484 get("/statuses/dm_timeline", TwitterAPI.Controller, :dm_timeline)
485 get("/qvitter/statuses/notifications", TwitterAPI.Controller, :notifications)
487 get("/pleroma/friend_requests", TwitterAPI.Controller, :friend_requests)
489 get("/friends/ids", TwitterAPI.Controller, :friends_ids)
490 get("/friendships/no_retweets/ids", TwitterAPI.Controller, :empty_array)
492 get("/mutes/users/ids", TwitterAPI.Controller, :empty_array)
493 get("/qvitter/mutes", TwitterAPI.Controller, :raw_empty_array)
495 get("/externalprofile/show", TwitterAPI.Controller, :external_profile)
497 post("/qvitter/statuses/notifications/read", TwitterAPI.Controller, :notifications_read)
501 pipe_through(:oauth_write)
503 post("/account/update_profile", TwitterAPI.Controller, :update_profile)
504 post("/account/update_profile_banner", TwitterAPI.Controller, :update_banner)
505 post("/qvitter/update_background_image", TwitterAPI.Controller, :update_background)
507 post("/statuses/update", TwitterAPI.Controller, :status_update)
508 post("/statuses/retweet/:id", TwitterAPI.Controller, :retweet)
509 post("/statuses/unretweet/:id", TwitterAPI.Controller, :unretweet)
510 post("/statuses/destroy/:id", TwitterAPI.Controller, :delete_post)
512 post("/statuses/pin/:id", TwitterAPI.Controller, :pin)
513 post("/statuses/unpin/:id", TwitterAPI.Controller, :unpin)
515 post("/statusnet/media/upload", TwitterAPI.Controller, :upload)
516 post("/media/upload", TwitterAPI.Controller, :upload_json)
517 post("/media/metadata/create", TwitterAPI.Controller, :update_media)
519 post("/favorites/create/:id", TwitterAPI.Controller, :favorite)
520 post("/favorites/create", TwitterAPI.Controller, :favorite)
521 post("/favorites/destroy/:id", TwitterAPI.Controller, :unfavorite)
523 post("/qvitter/update_avatar", TwitterAPI.Controller, :update_avatar)
527 pipe_through(:oauth_follow)
529 post("/pleroma/friendships/approve", TwitterAPI.Controller, :approve_friend_request)
530 post("/pleroma/friendships/deny", TwitterAPI.Controller, :deny_friend_request)
532 post("/friendships/create", TwitterAPI.Controller, :follow)
533 post("/friendships/destroy", TwitterAPI.Controller, :unfollow)
535 post("/blocks/create", TwitterAPI.Controller, :block)
536 post("/blocks/destroy", TwitterAPI.Controller, :unblock)
540 pipeline :ap_relay do
541 plug(:accepts, ["activity+json", "json"])
545 plug(:accepts, ["html", "xml", "atom", "activity+json", "json"])
549 plug(:accepts, ["json", "xml"])
552 scope "/", Pleroma.Web do
553 pipe_through(:ostatus)
555 get("/objects/:uuid", OStatus.OStatusController, :object)
556 get("/activities/:uuid", OStatus.OStatusController, :activity)
557 get("/notice/:id", OStatus.OStatusController, :notice)
558 get("/notice/:id/embed_player", OStatus.OStatusController, :notice_player)
559 get("/users/:nickname/feed", OStatus.OStatusController, :feed)
560 get("/users/:nickname", OStatus.OStatusController, :feed_redirect)
562 post("/users/:nickname/salmon", OStatus.OStatusController, :salmon_incoming)
563 post("/push/hub/:nickname", Websub.WebsubController, :websub_subscription_request)
564 get("/push/subscriptions/:id", Websub.WebsubController, :websub_subscription_confirmation)
565 post("/push/subscriptions/:id", Websub.WebsubController, :websub_incoming)
568 scope "/", Pleroma.Web do
569 pipe_through(:oembed)
571 get("/oembed", OEmbed.OEmbedController, :url)
574 pipeline :activitypub do
575 plug(:accepts, ["activity+json", "json"])
576 plug(Pleroma.Web.Plugs.HTTPSignaturePlug)
579 scope "/", Pleroma.Web.ActivityPub do
580 # XXX: not really ostatus
581 pipe_through(:ostatus)
583 get("/users/:nickname/followers", ActivityPubController, :followers)
584 get("/users/:nickname/following", ActivityPubController, :following)
585 get("/users/:nickname/outbox", ActivityPubController, :outbox)
586 get("/objects/:uuid/likes", ActivityPubController, :object_likes)
589 pipeline :activitypub_client do
590 plug(:accepts, ["activity+json", "json"])
592 plug(Pleroma.Plugs.OAuthPlug)
593 plug(Pleroma.Plugs.BasicAuthDecoderPlug)
594 plug(Pleroma.Plugs.UserFetcherPlug)
595 plug(Pleroma.Plugs.SessionAuthenticationPlug)
596 plug(Pleroma.Plugs.LegacyAuthenticationPlug)
597 plug(Pleroma.Plugs.AuthenticationPlug)
598 plug(Pleroma.Plugs.UserEnabledPlug)
599 plug(Pleroma.Plugs.SetUserSessionIdPlug)
600 plug(Pleroma.Plugs.EnsureUserKeyPlug)
603 scope "/", Pleroma.Web.ActivityPub do
604 pipe_through([:activitypub_client])
607 pipe_through(:oauth_read)
608 get("/api/ap/whoami", ActivityPubController, :whoami)
609 get("/users/:nickname/inbox", ActivityPubController, :read_inbox)
613 pipe_through(:oauth_write)
614 post("/users/:nickname/outbox", ActivityPubController, :update_outbox)
618 scope "/relay", Pleroma.Web.ActivityPub do
619 pipe_through(:ap_relay)
620 get("/", ActivityPubController, :relay)
623 scope "/", Pleroma.Web.ActivityPub do
624 pipe_through(:activitypub)
625 post("/inbox", ActivityPubController, :inbox)
626 post("/users/:nickname/inbox", ActivityPubController, :inbox)
629 scope "/.well-known", Pleroma.Web do
630 pipe_through(:well_known)
632 get("/host-meta", WebFinger.WebFingerController, :host_meta)
633 get("/webfinger", WebFinger.WebFingerController, :webfinger)
634 get("/nodeinfo", Nodeinfo.NodeinfoController, :schemas)
637 scope "/nodeinfo", Pleroma.Web do
638 get("/:version", Nodeinfo.NodeinfoController, :nodeinfo)
641 scope "/", Pleroma.Web.MastodonAPI do
642 pipe_through(:mastodon_html)
644 get("/web/login", MastodonAPIController, :login)
645 delete("/auth/sign_out", MastodonAPIController, :logout)
648 pipe_through(:oauth_read_or_unauthenticated)
649 get("/web/*path", MastodonAPIController, :index)
653 pipeline :remote_media do
656 scope "/proxy/", Pleroma.Web.MediaProxy do
657 pipe_through(:remote_media)
659 get("/:sig/:url", MediaProxyController, :remote)
660 get("/:sig/:url/:filename", MediaProxyController, :remote)
663 if Mix.env() == :dev do
665 pipe_through([:mailbox_preview])
667 forward("/mailbox", Plug.Swoosh.MailboxPreview, base_path: "/dev/mailbox")
671 scope "/", Fallback do
672 get("/registration/:token", RedirectController, :registration_page)
673 get("/:maybe_nickname_or_id", RedirectController, :redirector_with_meta)
674 get("/*path", RedirectController, :redirector)
676 options("/*path", RedirectController, :empty)
680 defmodule Fallback.RedirectController do
681 use Pleroma.Web, :controller
683 alias Pleroma.Web.Metadata
685 def redirector(conn, _params, code \\ 200) do
687 |> put_resp_content_type("text/html")
688 |> send_file(code, index_file_path())
691 def redirector_with_meta(conn, %{"maybe_nickname_or_id" => maybe_nickname_or_id} = params) do
692 with %User{} = user <- User.get_cached_by_nickname_or_id(maybe_nickname_or_id) do
693 redirector_with_meta(conn, %{user: user})
696 redirector(conn, params)
700 def redirector_with_meta(conn, params) do
701 {:ok, index_content} = File.read(index_file_path())
702 tags = Metadata.build_tags(params)
703 response = String.replace(index_content, "<!--server-generated-meta-->", tags)
706 |> put_resp_content_type("text/html")
707 |> send_resp(200, response)
710 def index_file_path do
711 Pleroma.Plugs.InstanceStatic.file_path("index.html")
714 def registration_page(conn, params) do
715 redirector(conn, params)
718 def empty(conn, _params) do