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("/conversations", MastodonAPIController, :conversations)
280 post("/conversations/:id/read", MastodonAPIController, :conversation_read)
282 get("/endorsements", MastodonAPIController, :empty_array)
284 get("/pleroma/flavour", MastodonAPIController, :get_flavour)
288 pipe_through(:oauth_write)
290 patch("/accounts/update_credentials", MastodonAPIController, :update_credentials)
292 post("/statuses", MastodonAPIController, :post_status)
293 delete("/statuses/:id", MastodonAPIController, :delete_status)
295 post("/statuses/:id/reblog", MastodonAPIController, :reblog_status)
296 post("/statuses/:id/unreblog", MastodonAPIController, :unreblog_status)
297 post("/statuses/:id/favourite", MastodonAPIController, :fav_status)
298 post("/statuses/:id/unfavourite", MastodonAPIController, :unfav_status)
299 post("/statuses/:id/pin", MastodonAPIController, :pin_status)
300 post("/statuses/:id/unpin", MastodonAPIController, :unpin_status)
301 post("/statuses/:id/bookmark", MastodonAPIController, :bookmark_status)
302 post("/statuses/:id/unbookmark", MastodonAPIController, :unbookmark_status)
303 post("/statuses/:id/mute", MastodonAPIController, :mute_conversation)
304 post("/statuses/:id/unmute", MastodonAPIController, :unmute_conversation)
306 put("/scheduled_statuses/:id", MastodonAPIController, :update_scheduled_status)
307 delete("/scheduled_statuses/:id", MastodonAPIController, :delete_scheduled_status)
309 post("/media", MastodonAPIController, :upload)
310 put("/media/:id", MastodonAPIController, :update_media)
312 delete("/lists/:id", MastodonAPIController, :delete_list)
313 post("/lists", MastodonAPIController, :create_list)
314 put("/lists/:id", MastodonAPIController, :rename_list)
316 post("/lists/:id/accounts", MastodonAPIController, :add_to_list)
317 delete("/lists/:id/accounts", MastodonAPIController, :remove_from_list)
319 post("/filters", MastodonAPIController, :create_filter)
320 get("/filters/:id", MastodonAPIController, :get_filter)
321 put("/filters/:id", MastodonAPIController, :update_filter)
322 delete("/filters/:id", MastodonAPIController, :delete_filter)
324 post("/pleroma/flavour/:flavour", MastodonAPIController, :set_flavour)
326 post("/reports", MastodonAPIController, :reports)
330 pipe_through(:oauth_follow)
332 post("/follows", MastodonAPIController, :follow)
333 post("/accounts/:id/follow", MastodonAPIController, :follow)
335 post("/accounts/:id/unfollow", MastodonAPIController, :unfollow)
336 post("/accounts/:id/block", MastodonAPIController, :block)
337 post("/accounts/:id/unblock", MastodonAPIController, :unblock)
338 post("/accounts/:id/mute", MastodonAPIController, :mute)
339 post("/accounts/:id/unmute", MastodonAPIController, :unmute)
341 post("/follow_requests/:id/authorize", MastodonAPIController, :authorize_follow_request)
342 post("/follow_requests/:id/reject", MastodonAPIController, :reject_follow_request)
344 post("/domain_blocks", MastodonAPIController, :block_domain)
345 delete("/domain_blocks", MastodonAPIController, :unblock_domain)
347 post("/pleroma/accounts/:id/subscribe", MastodonAPIController, :subscribe)
348 post("/pleroma/accounts/:id/unsubscribe", MastodonAPIController, :unsubscribe)
352 pipe_through(:oauth_push)
354 post("/push/subscription", SubscriptionController, :create)
355 get("/push/subscription", SubscriptionController, :get)
356 put("/push/subscription", SubscriptionController, :update)
357 delete("/push/subscription", SubscriptionController, :delete)
361 scope "/api/web", Pleroma.Web.MastodonAPI do
362 pipe_through([:authenticated_api, :oauth_write])
364 put("/settings", MastodonAPIController, :put_settings)
367 scope "/api/v1", Pleroma.Web.MastodonAPI do
370 get("/instance", MastodonAPIController, :masto_instance)
371 get("/instance/peers", MastodonAPIController, :peers)
372 post("/apps", MastodonAPIController, :create_app)
373 get("/apps/verify_credentials", MastodonAPIController, :verify_app_credentials)
374 get("/custom_emojis", MastodonAPIController, :custom_emojis)
376 get("/statuses/:id/card", MastodonAPIController, :status_card)
378 get("/statuses/:id/favourited_by", MastodonAPIController, :favourited_by)
379 get("/statuses/:id/reblogged_by", MastodonAPIController, :reblogged_by)
381 get("/trends", MastodonAPIController, :empty_array)
383 get("/accounts/search", MastodonAPIController, :account_search)
386 pipe_through(:oauth_read_or_unauthenticated)
388 get("/timelines/public", MastodonAPIController, :public_timeline)
389 get("/timelines/tag/:tag", MastodonAPIController, :hashtag_timeline)
390 get("/timelines/list/:list_id", MastodonAPIController, :list_timeline)
392 get("/statuses/:id", MastodonAPIController, :get_status)
393 get("/statuses/:id/context", MastodonAPIController, :get_context)
395 get("/accounts/:id/statuses", MastodonAPIController, :user_statuses)
396 get("/accounts/:id/followers", MastodonAPIController, :followers)
397 get("/accounts/:id/following", MastodonAPIController, :following)
398 get("/accounts/:id", MastodonAPIController, :user)
400 get("/search", MastodonAPIController, :search)
402 get("/pleroma/accounts/:id/favourites", MastodonAPIController, :user_favourites)
406 scope "/api/v2", Pleroma.Web.MastodonAPI do
407 pipe_through([:api, :oauth_read_or_unauthenticated])
408 get("/search", MastodonAPIController, :search2)
411 scope "/api", Pleroma.Web do
412 pipe_through(:config)
414 get("/help/test", TwitterAPI.UtilController, :help_test)
415 post("/help/test", TwitterAPI.UtilController, :help_test)
416 get("/statusnet/config", TwitterAPI.UtilController, :config)
417 get("/statusnet/version", TwitterAPI.UtilController, :version)
418 get("/pleroma/frontend_configurations", TwitterAPI.UtilController, :frontend_configurations)
421 scope "/api", Pleroma.Web do
424 post("/account/register", TwitterAPI.Controller, :register)
425 post("/account/password_reset", TwitterAPI.Controller, :password_reset)
427 post("/account/resend_confirmation_email", TwitterAPI.Controller, :resend_confirmation_email)
430 "/account/confirm_email/:user_id/:token",
431 TwitterAPI.Controller,
437 pipe_through(:oauth_read_or_unauthenticated)
439 get("/statuses/user_timeline", TwitterAPI.Controller, :user_timeline)
440 get("/qvitter/statuses/user_timeline", TwitterAPI.Controller, :user_timeline)
441 get("/users/show", TwitterAPI.Controller, :show_user)
443 get("/statuses/followers", TwitterAPI.Controller, :followers)
444 get("/statuses/friends", TwitterAPI.Controller, :friends)
445 get("/statuses/blocks", TwitterAPI.Controller, :blocks)
446 get("/statuses/show/:id", TwitterAPI.Controller, :fetch_status)
447 get("/statusnet/conversation/:id", TwitterAPI.Controller, :fetch_conversation)
449 get("/search", TwitterAPI.Controller, :search)
450 get("/statusnet/tags/timeline/:tag", TwitterAPI.Controller, :public_and_external_timeline)
454 scope "/api", Pleroma.Web do
455 pipe_through([:api, :oauth_read_or_unauthenticated])
457 get("/statuses/public_timeline", TwitterAPI.Controller, :public_timeline)
460 "/statuses/public_and_external_timeline",
461 TwitterAPI.Controller,
462 :public_and_external_timeline
465 get("/statuses/networkpublic_timeline", TwitterAPI.Controller, :public_and_external_timeline)
468 scope "/api", Pleroma.Web, as: :twitter_api_search do
469 pipe_through([:api, :oauth_read_or_unauthenticated])
470 get("/pleroma/search_user", TwitterAPI.Controller, :search_user)
473 scope "/api", Pleroma.Web, as: :authenticated_twitter_api do
474 pipe_through(:authenticated_api)
476 get("/oauth_tokens", TwitterAPI.Controller, :oauth_tokens)
477 delete("/oauth_tokens/:id", TwitterAPI.Controller, :revoke_token)
480 pipe_through(:oauth_read)
482 get("/account/verify_credentials", TwitterAPI.Controller, :verify_credentials)
483 post("/account/verify_credentials", TwitterAPI.Controller, :verify_credentials)
485 get("/statuses/home_timeline", TwitterAPI.Controller, :friends_timeline)
486 get("/statuses/friends_timeline", TwitterAPI.Controller, :friends_timeline)
487 get("/statuses/mentions", TwitterAPI.Controller, :mentions_timeline)
488 get("/statuses/mentions_timeline", TwitterAPI.Controller, :mentions_timeline)
489 get("/statuses/dm_timeline", TwitterAPI.Controller, :dm_timeline)
490 get("/qvitter/statuses/notifications", TwitterAPI.Controller, :notifications)
492 get("/pleroma/friend_requests", TwitterAPI.Controller, :friend_requests)
494 get("/friends/ids", TwitterAPI.Controller, :friends_ids)
495 get("/friendships/no_retweets/ids", TwitterAPI.Controller, :empty_array)
497 get("/mutes/users/ids", TwitterAPI.Controller, :empty_array)
498 get("/qvitter/mutes", TwitterAPI.Controller, :raw_empty_array)
500 get("/externalprofile/show", TwitterAPI.Controller, :external_profile)
502 post("/qvitter/statuses/notifications/read", TwitterAPI.Controller, :notifications_read)
506 pipe_through(:oauth_write)
508 post("/account/update_profile", TwitterAPI.Controller, :update_profile)
509 post("/account/update_profile_banner", TwitterAPI.Controller, :update_banner)
510 post("/qvitter/update_background_image", TwitterAPI.Controller, :update_background)
512 post("/statuses/update", TwitterAPI.Controller, :status_update)
513 post("/statuses/retweet/:id", TwitterAPI.Controller, :retweet)
514 post("/statuses/unretweet/:id", TwitterAPI.Controller, :unretweet)
515 post("/statuses/destroy/:id", TwitterAPI.Controller, :delete_post)
517 post("/statuses/pin/:id", TwitterAPI.Controller, :pin)
518 post("/statuses/unpin/:id", TwitterAPI.Controller, :unpin)
520 post("/statusnet/media/upload", TwitterAPI.Controller, :upload)
521 post("/media/upload", TwitterAPI.Controller, :upload_json)
522 post("/media/metadata/create", TwitterAPI.Controller, :update_media)
524 post("/favorites/create/:id", TwitterAPI.Controller, :favorite)
525 post("/favorites/create", TwitterAPI.Controller, :favorite)
526 post("/favorites/destroy/:id", TwitterAPI.Controller, :unfavorite)
528 post("/qvitter/update_avatar", TwitterAPI.Controller, :update_avatar)
532 pipe_through(:oauth_follow)
534 post("/pleroma/friendships/approve", TwitterAPI.Controller, :approve_friend_request)
535 post("/pleroma/friendships/deny", TwitterAPI.Controller, :deny_friend_request)
537 post("/friendships/create", TwitterAPI.Controller, :follow)
538 post("/friendships/destroy", TwitterAPI.Controller, :unfollow)
540 post("/blocks/create", TwitterAPI.Controller, :block)
541 post("/blocks/destroy", TwitterAPI.Controller, :unblock)
545 pipeline :ap_relay do
546 plug(:accepts, ["activity+json", "json"])
550 plug(:accepts, ["html", "xml", "atom", "activity+json", "json"])
554 plug(:accepts, ["json", "xml"])
557 scope "/", Pleroma.Web do
558 pipe_through(:ostatus)
560 get("/objects/:uuid", OStatus.OStatusController, :object)
561 get("/activities/:uuid", OStatus.OStatusController, :activity)
562 get("/notice/:id", OStatus.OStatusController, :notice)
563 get("/notice/:id/embed_player", OStatus.OStatusController, :notice_player)
564 get("/users/:nickname/feed", OStatus.OStatusController, :feed)
565 get("/users/:nickname", OStatus.OStatusController, :feed_redirect)
567 post("/users/:nickname/salmon", OStatus.OStatusController, :salmon_incoming)
568 post("/push/hub/:nickname", Websub.WebsubController, :websub_subscription_request)
569 get("/push/subscriptions/:id", Websub.WebsubController, :websub_subscription_confirmation)
570 post("/push/subscriptions/:id", Websub.WebsubController, :websub_incoming)
573 scope "/", Pleroma.Web do
574 pipe_through(:oembed)
576 get("/oembed", OEmbed.OEmbedController, :url)
579 pipeline :activitypub do
580 plug(:accepts, ["activity+json", "json"])
581 plug(Pleroma.Web.Plugs.HTTPSignaturePlug)
584 scope "/", Pleroma.Web.ActivityPub do
585 # XXX: not really ostatus
586 pipe_through(:ostatus)
588 get("/users/:nickname/followers", ActivityPubController, :followers)
589 get("/users/:nickname/following", ActivityPubController, :following)
590 get("/users/:nickname/outbox", ActivityPubController, :outbox)
591 get("/objects/:uuid/likes", ActivityPubController, :object_likes)
594 pipeline :activitypub_client do
595 plug(:accepts, ["activity+json", "json"])
597 plug(Pleroma.Plugs.OAuthPlug)
598 plug(Pleroma.Plugs.BasicAuthDecoderPlug)
599 plug(Pleroma.Plugs.UserFetcherPlug)
600 plug(Pleroma.Plugs.SessionAuthenticationPlug)
601 plug(Pleroma.Plugs.LegacyAuthenticationPlug)
602 plug(Pleroma.Plugs.AuthenticationPlug)
603 plug(Pleroma.Plugs.UserEnabledPlug)
604 plug(Pleroma.Plugs.SetUserSessionIdPlug)
605 plug(Pleroma.Plugs.EnsureUserKeyPlug)
608 scope "/", Pleroma.Web.ActivityPub do
609 pipe_through([:activitypub_client])
612 pipe_through(:oauth_read)
613 get("/api/ap/whoami", ActivityPubController, :whoami)
614 get("/users/:nickname/inbox", ActivityPubController, :read_inbox)
618 pipe_through(:oauth_write)
619 post("/users/:nickname/outbox", ActivityPubController, :update_outbox)
623 scope "/relay", Pleroma.Web.ActivityPub do
624 pipe_through(:ap_relay)
625 get("/", ActivityPubController, :relay)
628 scope "/", Pleroma.Web.ActivityPub do
629 pipe_through(:activitypub)
630 post("/inbox", ActivityPubController, :inbox)
631 post("/users/:nickname/inbox", ActivityPubController, :inbox)
634 scope "/.well-known", Pleroma.Web do
635 pipe_through(:well_known)
637 get("/host-meta", WebFinger.WebFingerController, :host_meta)
638 get("/webfinger", WebFinger.WebFingerController, :webfinger)
639 get("/nodeinfo", Nodeinfo.NodeinfoController, :schemas)
642 scope "/nodeinfo", Pleroma.Web do
643 get("/:version", Nodeinfo.NodeinfoController, :nodeinfo)
646 scope "/", Pleroma.Web.MastodonAPI do
647 pipe_through(:mastodon_html)
649 get("/web/login", MastodonAPIController, :login)
650 delete("/auth/sign_out", MastodonAPIController, :logout)
653 pipe_through(:oauth_read_or_unauthenticated)
654 get("/web/*path", MastodonAPIController, :index)
658 pipeline :remote_media do
661 scope "/proxy/", Pleroma.Web.MediaProxy do
662 pipe_through(:remote_media)
664 get("/:sig/:url", MediaProxyController, :remote)
665 get("/:sig/:url/:filename", MediaProxyController, :remote)
668 if Mix.env() == :dev do
670 pipe_through([:mailbox_preview])
672 forward("/mailbox", Plug.Swoosh.MailboxPreview, base_path: "/dev/mailbox")
676 scope "/", Fallback do
677 get("/registration/:token", RedirectController, :registration_page)
678 get("/:maybe_nickname_or_id", RedirectController, :redirector_with_meta)
679 get("/*path", RedirectController, :redirector)
681 options("/*path", RedirectController, :empty)
685 defmodule Fallback.RedirectController do
686 use Pleroma.Web, :controller
688 alias Pleroma.Web.Metadata
690 def redirector(conn, _params, code \\ 200) do
692 |> put_resp_content_type("text/html")
693 |> send_file(code, index_file_path())
696 def redirector_with_meta(conn, %{"maybe_nickname_or_id" => maybe_nickname_or_id} = params) do
697 with %User{} = user <- User.get_cached_by_nickname_or_id(maybe_nickname_or_id) do
698 redirector_with_meta(conn, %{user: user})
701 redirector(conn, params)
705 def redirector_with_meta(conn, params) do
706 {:ok, index_content} = File.read(index_file_path())
707 tags = Metadata.build_tags(params)
708 response = String.replace(index_content, "<!--server-generated-meta-->", tags)
711 |> put_resp_content_type("text/html")
712 |> send_resp(200, response)
715 def index_file_path do
716 Pleroma.Plugs.InstanceStatic.file_path("index.html")
719 def registration_page(conn, params) do
720 redirector(conn, params)
723 def empty(conn, _params) do