Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into remake-remodel-dms
[akkoma] / lib / pleroma / web / router.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.Router do
6 use Pleroma.Web, :router
7
8 pipeline :browser do
9 plug(:accepts, ["html"])
10 plug(:fetch_session)
11 end
12
13 pipeline :oauth do
14 plug(:fetch_session)
15 plug(Pleroma.Plugs.OAuthPlug)
16 plug(Pleroma.Plugs.UserEnabledPlug)
17 end
18
19 pipeline :authenticate do
20 plug(Pleroma.Plugs.OAuthPlug)
21 plug(Pleroma.Plugs.BasicAuthDecoderPlug)
22 plug(Pleroma.Plugs.UserFetcherPlug)
23 plug(Pleroma.Plugs.SessionAuthenticationPlug)
24 plug(Pleroma.Plugs.LegacyAuthenticationPlug)
25 plug(Pleroma.Plugs.AuthenticationPlug)
26 end
27
28 pipeline :after_auth do
29 plug(Pleroma.Plugs.UserEnabledPlug)
30 plug(Pleroma.Plugs.SetUserSessionIdPlug)
31 plug(Pleroma.Plugs.EnsureUserKeyPlug)
32 end
33
34 pipeline :base_api do
35 plug(:accepts, ["json"])
36 plug(:fetch_session)
37 plug(:authenticate)
38 plug(OpenApiSpex.Plug.PutApiSpec, module: Pleroma.Web.ApiSpec)
39 end
40
41 pipeline :api do
42 plug(:base_api)
43 plug(:after_auth)
44 plug(Pleroma.Plugs.IdempotencyPlug)
45 end
46
47 pipeline :authenticated_api do
48 plug(:base_api)
49 plug(Pleroma.Plugs.AuthExpectedPlug)
50 plug(:after_auth)
51 plug(Pleroma.Plugs.EnsureAuthenticatedPlug)
52 plug(Pleroma.Plugs.IdempotencyPlug)
53 end
54
55 pipeline :admin_api do
56 plug(:base_api)
57 plug(Pleroma.Plugs.AdminSecretAuthenticationPlug)
58 plug(:after_auth)
59 plug(Pleroma.Plugs.EnsureAuthenticatedPlug)
60 plug(Pleroma.Plugs.UserIsAdminPlug)
61 plug(Pleroma.Plugs.IdempotencyPlug)
62 end
63
64 pipeline :mastodon_html do
65 plug(:browser)
66 plug(:authenticate)
67 plug(:after_auth)
68 end
69
70 pipeline :pleroma_html do
71 plug(:browser)
72 plug(:authenticate)
73 plug(Pleroma.Plugs.EnsureUserKeyPlug)
74 end
75
76 pipeline :well_known do
77 plug(:accepts, ["json", "jrd+json", "xml", "xrd+xml"])
78 end
79
80 pipeline :config do
81 plug(:accepts, ["json", "xml"])
82 plug(OpenApiSpex.Plug.PutApiSpec, module: Pleroma.Web.ApiSpec)
83 end
84
85 pipeline :pleroma_api do
86 plug(:accepts, ["html", "json"])
87 plug(OpenApiSpex.Plug.PutApiSpec, module: Pleroma.Web.ApiSpec)
88 end
89
90 pipeline :mailbox_preview do
91 plug(:accepts, ["html"])
92
93 plug(:put_secure_browser_headers, %{
94 "content-security-policy" =>
95 "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline' 'unsafe-eval'"
96 })
97 end
98
99 pipeline :http_signature do
100 plug(Pleroma.Web.Plugs.HTTPSignaturePlug)
101 plug(Pleroma.Web.Plugs.MappedSignatureToIdentityPlug)
102 end
103
104 scope "/api/pleroma", Pleroma.Web.TwitterAPI do
105 pipe_through(:pleroma_api)
106
107 get("/password_reset/:token", PasswordController, :reset, as: :reset_password)
108 post("/password_reset", PasswordController, :do_reset, as: :reset_password)
109 get("/emoji", UtilController, :emoji)
110 get("/captcha", UtilController, :captcha)
111 get("/healthcheck", UtilController, :healthcheck)
112 end
113
114 scope "/api/pleroma", Pleroma.Web do
115 pipe_through(:pleroma_api)
116 post("/uploader_callback/:upload_path", UploaderController, :callback)
117 end
118
119 scope "/api/pleroma/admin", Pleroma.Web.AdminAPI do
120 pipe_through(:admin_api)
121
122 post("/users/follow", AdminAPIController, :user_follow)
123 post("/users/unfollow", AdminAPIController, :user_unfollow)
124
125 delete("/users", AdminAPIController, :user_delete)
126 post("/users", AdminAPIController, :users_create)
127 patch("/users/:nickname/toggle_activation", AdminAPIController, :user_toggle_activation)
128 patch("/users/activate", AdminAPIController, :user_activate)
129 patch("/users/deactivate", AdminAPIController, :user_deactivate)
130 put("/users/tag", AdminAPIController, :tag_users)
131 delete("/users/tag", AdminAPIController, :untag_users)
132
133 get("/users/:nickname/permission_group", AdminAPIController, :right_get)
134 get("/users/:nickname/permission_group/:permission_group", AdminAPIController, :right_get)
135
136 post("/users/:nickname/permission_group/:permission_group", AdminAPIController, :right_add)
137
138 delete(
139 "/users/:nickname/permission_group/:permission_group",
140 AdminAPIController,
141 :right_delete
142 )
143
144 post("/users/permission_group/:permission_group", AdminAPIController, :right_add_multiple)
145
146 delete(
147 "/users/permission_group/:permission_group",
148 AdminAPIController,
149 :right_delete_multiple
150 )
151
152 get("/relay", AdminAPIController, :relay_list)
153 post("/relay", AdminAPIController, :relay_follow)
154 delete("/relay", AdminAPIController, :relay_unfollow)
155
156 post("/users/invite_token", AdminAPIController, :create_invite_token)
157 get("/users/invites", AdminAPIController, :invites)
158 post("/users/revoke_invite", AdminAPIController, :revoke_invite)
159 post("/users/email_invite", AdminAPIController, :email_invite)
160
161 get("/users/:nickname/password_reset", AdminAPIController, :get_password_reset)
162 patch("/users/force_password_reset", AdminAPIController, :force_password_reset)
163 get("/users/:nickname/credentials", AdminAPIController, :show_user_credentials)
164 patch("/users/:nickname/credentials", AdminAPIController, :update_user_credentials)
165
166 get("/users", AdminAPIController, :list_users)
167 get("/users/:nickname", AdminAPIController, :user_show)
168 get("/users/:nickname/statuses", AdminAPIController, :list_user_statuses)
169
170 get("/instances/:instance/statuses", AdminAPIController, :list_instance_statuses)
171
172 patch("/users/confirm_email", AdminAPIController, :confirm_email)
173 patch("/users/resend_confirmation_email", AdminAPIController, :resend_confirmation_email)
174
175 get("/reports", AdminAPIController, :list_reports)
176 get("/reports/:id", AdminAPIController, :report_show)
177 patch("/reports", AdminAPIController, :reports_update)
178 post("/reports/:id/notes", AdminAPIController, :report_notes_create)
179 delete("/reports/:report_id/notes/:id", AdminAPIController, :report_notes_delete)
180
181 put("/statuses/:id", AdminAPIController, :status_update)
182 delete("/statuses/:id", AdminAPIController, :status_delete)
183 get("/statuses", AdminAPIController, :list_statuses)
184
185 get("/config", AdminAPIController, :config_show)
186 post("/config", AdminAPIController, :config_update)
187 get("/config/descriptions", AdminAPIController, :config_descriptions)
188 get("/need_reboot", AdminAPIController, :need_reboot)
189 get("/restart", AdminAPIController, :restart)
190
191 get("/moderation_log", AdminAPIController, :list_log)
192
193 post("/reload_emoji", AdminAPIController, :reload_emoji)
194 get("/stats", AdminAPIController, :stats)
195
196 get("/oauth_app", AdminAPIController, :oauth_app_list)
197 post("/oauth_app", AdminAPIController, :oauth_app_create)
198 patch("/oauth_app/:id", AdminAPIController, :oauth_app_update)
199 delete("/oauth_app/:id", AdminAPIController, :oauth_app_delete)
200 end
201
202 scope "/api/pleroma/emoji", Pleroma.Web.PleromaAPI do
203 scope "/packs" do
204 # Modifying packs
205 pipe_through(:admin_api)
206
207 post("/import_from_fs", EmojiAPIController, :import_from_fs)
208
209 post("/:pack_name/update_file", EmojiAPIController, :update_file)
210 post("/:pack_name/update_metadata", EmojiAPIController, :update_metadata)
211 put("/:name", EmojiAPIController, :create)
212 delete("/:name", EmojiAPIController, :delete)
213 post("/download_from", EmojiAPIController, :download_from)
214 post("/list_from", EmojiAPIController, :list_from)
215 end
216
217 scope "/packs" do
218 # Pack info / downloading
219 get("/", EmojiAPIController, :list_packs)
220 get("/:name/download_shared/", EmojiAPIController, :download_shared)
221 end
222 end
223
224 scope "/", Pleroma.Web.TwitterAPI do
225 pipe_through(:pleroma_html)
226
227 post("/main/ostatus", UtilController, :remote_subscribe)
228 get("/ostatus_subscribe", RemoteFollowController, :follow)
229
230 post("/ostatus_subscribe", RemoteFollowController, :do_follow)
231 end
232
233 scope "/api/pleroma", Pleroma.Web.TwitterAPI do
234 pipe_through(:authenticated_api)
235
236 post("/change_email", UtilController, :change_email)
237 post("/change_password", UtilController, :change_password)
238 post("/delete_account", UtilController, :delete_account)
239 put("/notification_settings", UtilController, :update_notificaton_settings)
240 post("/disable_account", UtilController, :disable_account)
241
242 post("/blocks_import", UtilController, :blocks_import)
243 post("/follow_import", UtilController, :follow_import)
244 end
245
246 scope "/oauth", Pleroma.Web.OAuth do
247 scope [] do
248 pipe_through(:oauth)
249 get("/authorize", OAuthController, :authorize)
250 end
251
252 post("/authorize", OAuthController, :create_authorization)
253 post("/token", OAuthController, :token_exchange)
254 post("/revoke", OAuthController, :token_revoke)
255 get("/registration_details", OAuthController, :registration_details)
256
257 scope [] do
258 pipe_through(:browser)
259
260 get("/prepare_request", OAuthController, :prepare_request)
261 get("/:provider", OAuthController, :request)
262 get("/:provider/callback", OAuthController, :callback)
263 post("/register", OAuthController, :register)
264 end
265 end
266
267 scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do
268 pipe_through(:api)
269
270 get("/statuses/:id/reactions/:emoji", PleromaAPIController, :emoji_reactions_by)
271 get("/statuses/:id/reactions", PleromaAPIController, :emoji_reactions_by)
272 end
273
274 scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do
275 scope [] do
276 pipe_through(:authenticated_api)
277
278 post("/chats/by-ap-id/:ap_id", ChatController, :create)
279 get("/chats", ChatController, :index)
280 get("/chats/:id/messages", ChatController, :messages)
281 post("/chats/:id/messages", ChatController, :post_chat_message)
282 end
283
284 scope [] do
285 pipe_through(:authenticated_api)
286
287 get("/conversations/:id/statuses", PleromaAPIController, :conversation_statuses)
288 get("/conversations/:id", PleromaAPIController, :conversation)
289 post("/conversations/read", PleromaAPIController, :read_conversations)
290 end
291
292 scope [] do
293 pipe_through(:authenticated_api)
294
295 patch("/conversations/:id", PleromaAPIController, :update_conversation)
296 put("/statuses/:id/reactions/:emoji", PleromaAPIController, :react_with_emoji)
297 delete("/statuses/:id/reactions/:emoji", PleromaAPIController, :unreact_with_emoji)
298 post("/notifications/read", PleromaAPIController, :read_notification)
299
300 patch("/accounts/update_avatar", AccountController, :update_avatar)
301 patch("/accounts/update_banner", AccountController, :update_banner)
302 patch("/accounts/update_background", AccountController, :update_background)
303
304 get("/mascot", MascotController, :show)
305 put("/mascot", MascotController, :update)
306
307 post("/scrobble", ScrobbleController, :new_scrobble)
308 end
309
310 scope [] do
311 pipe_through(:api)
312 get("/accounts/:id/favourites", AccountController, :favourites)
313 end
314
315 scope [] do
316 pipe_through(:authenticated_api)
317
318 post("/accounts/:id/subscribe", AccountController, :subscribe)
319 post("/accounts/:id/unsubscribe", AccountController, :unsubscribe)
320 end
321
322 post("/accounts/confirmation_resend", AccountController, :confirmation_resend)
323 end
324
325 scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do
326 pipe_through(:api)
327 get("/accounts/:id/scrobbles", ScrobbleController, :user_scrobbles)
328 end
329
330 scope "/api/v1", Pleroma.Web.MastodonAPI do
331 pipe_through(:authenticated_api)
332
333 get("/accounts/verify_credentials", AccountController, :verify_credentials)
334
335 get("/accounts/relationships", AccountController, :relationships)
336
337 get("/accounts/:id/lists", AccountController, :lists)
338 get("/accounts/:id/identity_proofs", AccountController, :identity_proofs)
339
340 get("/follow_requests", FollowRequestController, :index)
341 get("/blocks", AccountController, :blocks)
342 get("/mutes", AccountController, :mutes)
343
344 get("/timelines/home", TimelineController, :home)
345 get("/timelines/direct", TimelineController, :direct)
346
347 get("/favourites", StatusController, :favourites)
348 get("/bookmarks", StatusController, :bookmarks)
349
350 get("/notifications", NotificationController, :index)
351 get("/notifications/:id", NotificationController, :show)
352 post("/notifications/:id/dismiss", NotificationController, :dismiss)
353 post("/notifications/clear", NotificationController, :clear)
354 delete("/notifications/destroy_multiple", NotificationController, :destroy_multiple)
355 # Deprecated: was removed in Mastodon v3, use `/notifications/:id/dismiss` instead
356 post("/notifications/dismiss", NotificationController, :dismiss)
357
358 get("/scheduled_statuses", ScheduledActivityController, :index)
359 get("/scheduled_statuses/:id", ScheduledActivityController, :show)
360
361 get("/lists", ListController, :index)
362 get("/lists/:id", ListController, :show)
363 get("/lists/:id/accounts", ListController, :list_accounts)
364
365 get("/domain_blocks", DomainBlockController, :index)
366
367 get("/filters", FilterController, :index)
368
369 get("/suggestions", SuggestionController, :index)
370
371 get("/conversations", ConversationController, :index)
372 post("/conversations/:id/read", ConversationController, :read)
373
374 get("/endorsements", AccountController, :endorsements)
375
376 patch("/accounts/update_credentials", AccountController, :update_credentials)
377
378 post("/statuses", StatusController, :create)
379 delete("/statuses/:id", StatusController, :delete)
380
381 post("/statuses/:id/reblog", StatusController, :reblog)
382 post("/statuses/:id/unreblog", StatusController, :unreblog)
383 post("/statuses/:id/favourite", StatusController, :favourite)
384 post("/statuses/:id/unfavourite", StatusController, :unfavourite)
385 post("/statuses/:id/pin", StatusController, :pin)
386 post("/statuses/:id/unpin", StatusController, :unpin)
387 post("/statuses/:id/bookmark", StatusController, :bookmark)
388 post("/statuses/:id/unbookmark", StatusController, :unbookmark)
389 post("/statuses/:id/mute", StatusController, :mute_conversation)
390 post("/statuses/:id/unmute", StatusController, :unmute_conversation)
391
392 put("/scheduled_statuses/:id", ScheduledActivityController, :update)
393 delete("/scheduled_statuses/:id", ScheduledActivityController, :delete)
394
395 post("/polls/:id/votes", PollController, :vote)
396
397 post("/media", MediaController, :create)
398 put("/media/:id", MediaController, :update)
399
400 delete("/lists/:id", ListController, :delete)
401 post("/lists", ListController, :create)
402 put("/lists/:id", ListController, :update)
403
404 post("/lists/:id/accounts", ListController, :add_to_list)
405 delete("/lists/:id/accounts", ListController, :remove_from_list)
406
407 post("/filters", FilterController, :create)
408 get("/filters/:id", FilterController, :show)
409 put("/filters/:id", FilterController, :update)
410 delete("/filters/:id", FilterController, :delete)
411
412 post("/reports", ReportController, :create)
413
414 post("/follows", AccountController, :follows)
415 post("/accounts/:id/follow", AccountController, :follow)
416 post("/accounts/:id/unfollow", AccountController, :unfollow)
417 post("/accounts/:id/block", AccountController, :block)
418 post("/accounts/:id/unblock", AccountController, :unblock)
419 post("/accounts/:id/mute", AccountController, :mute)
420 post("/accounts/:id/unmute", AccountController, :unmute)
421
422 post("/follow_requests/:id/authorize", FollowRequestController, :authorize)
423 post("/follow_requests/:id/reject", FollowRequestController, :reject)
424
425 post("/domain_blocks", DomainBlockController, :create)
426 delete("/domain_blocks", DomainBlockController, :delete)
427
428 post("/push/subscription", SubscriptionController, :create)
429 get("/push/subscription", SubscriptionController, :get)
430 put("/push/subscription", SubscriptionController, :update)
431 delete("/push/subscription", SubscriptionController, :delete)
432
433 get("/markers", MarkerController, :index)
434 post("/markers", MarkerController, :upsert)
435 end
436
437 scope "/api/web", Pleroma.Web do
438 pipe_through(:authenticated_api)
439
440 put("/settings", MastoFEController, :put_settings)
441 end
442
443 scope "/api/v1", Pleroma.Web.MastodonAPI do
444 pipe_through(:api)
445
446 post("/accounts", AccountController, :create)
447 get("/accounts/search", SearchController, :account_search)
448
449 get("/instance", InstanceController, :show)
450 get("/instance/peers", InstanceController, :peers)
451
452 post("/apps", AppController, :create)
453 get("/apps/verify_credentials", AppController, :verify_credentials)
454
455 get("/statuses/:id/card", StatusController, :card)
456 get("/statuses/:id/favourited_by", StatusController, :favourited_by)
457 get("/statuses/:id/reblogged_by", StatusController, :reblogged_by)
458
459 get("/custom_emojis", CustomEmojiController, :index)
460
461 get("/trends", MastodonAPIController, :empty_array)
462
463 get("/timelines/public", TimelineController, :public)
464 get("/timelines/tag/:tag", TimelineController, :hashtag)
465 get("/timelines/list/:list_id", TimelineController, :list)
466
467 get("/statuses", StatusController, :index)
468 get("/statuses/:id", StatusController, :show)
469 get("/statuses/:id/context", StatusController, :context)
470
471 get("/polls/:id", PollController, :show)
472
473 get("/accounts/:id/statuses", AccountController, :statuses)
474 get("/accounts/:id/followers", AccountController, :followers)
475 get("/accounts/:id/following", AccountController, :following)
476 get("/accounts/:id", AccountController, :show)
477
478 get("/search", SearchController, :search)
479 end
480
481 scope "/api/v2", Pleroma.Web.MastodonAPI do
482 pipe_through(:api)
483 get("/search", SearchController, :search2)
484 end
485
486 scope "/api", Pleroma.Web do
487 pipe_through(:config)
488
489 get("/help/test", TwitterAPI.UtilController, :help_test)
490 post("/help/test", TwitterAPI.UtilController, :help_test)
491 get("/statusnet/config", TwitterAPI.UtilController, :config)
492 get("/statusnet/version", TwitterAPI.UtilController, :version)
493 get("/pleroma/frontend_configurations", TwitterAPI.UtilController, :frontend_configurations)
494 end
495
496 scope "/api", Pleroma.Web do
497 pipe_through(:api)
498
499 get(
500 "/account/confirm_email/:user_id/:token",
501 TwitterAPI.Controller,
502 :confirm_email,
503 as: :confirm_email
504 )
505 end
506
507 scope "/api" do
508 pipe_through(:base_api)
509
510 get("/openapi", OpenApiSpex.Plug.RenderSpec, [])
511 end
512
513 scope "/api", Pleroma.Web, as: :authenticated_twitter_api do
514 pipe_through(:authenticated_api)
515
516 get("/oauth_tokens", TwitterAPI.Controller, :oauth_tokens)
517 delete("/oauth_tokens/:id", TwitterAPI.Controller, :revoke_token)
518
519 post("/qvitter/statuses/notifications/read", TwitterAPI.Controller, :notifications_read)
520 end
521
522 pipeline :ostatus do
523 plug(:accepts, ["html", "xml", "rss", "atom", "activity+json", "json"])
524 plug(Pleroma.Plugs.StaticFEPlug)
525 end
526
527 pipeline :oembed do
528 plug(:accepts, ["json", "xml"])
529 end
530
531 scope "/", Pleroma.Web do
532 pipe_through([:ostatus, :http_signature])
533
534 get("/objects/:uuid", OStatus.OStatusController, :object)
535 get("/activities/:uuid", OStatus.OStatusController, :activity)
536 get("/notice/:id", OStatus.OStatusController, :notice)
537 get("/notice/:id/embed_player", OStatus.OStatusController, :notice_player)
538
539 get("/users/:nickname/feed", Feed.UserController, :feed, as: :user_feed)
540 get("/users/:nickname", Feed.UserController, :feed_redirect, as: :user_feed)
541
542 get("/tags/:tag", Feed.TagController, :feed, as: :tag_feed)
543 end
544
545 scope "/", Pleroma.Web do
546 pipe_through(:browser)
547 get("/mailer/unsubscribe/:token", Mailer.SubscriptionController, :unsubscribe)
548 end
549
550 scope "/", Pleroma.Web.ActivityPub do
551 # XXX: not really ostatus
552 pipe_through(:ostatus)
553
554 get("/users/:nickname/outbox", ActivityPubController, :outbox)
555 end
556
557 pipeline :ap_service_actor do
558 plug(:accepts, ["activity+json", "json"])
559 end
560
561 # Server to Server (S2S) AP interactions
562 pipeline :activitypub do
563 plug(:ap_service_actor)
564 plug(:http_signature)
565 end
566
567 # Client to Server (C2S) AP interactions
568 pipeline :activitypub_client do
569 plug(:ap_service_actor)
570 plug(:fetch_session)
571 plug(:authenticate)
572 plug(:after_auth)
573 end
574
575 scope "/", Pleroma.Web.ActivityPub do
576 pipe_through([:activitypub_client])
577
578 get("/api/ap/whoami", ActivityPubController, :whoami)
579 get("/users/:nickname/inbox", ActivityPubController, :read_inbox)
580
581 post("/users/:nickname/outbox", ActivityPubController, :update_outbox)
582 post("/api/ap/upload_media", ActivityPubController, :upload_media)
583
584 get("/users/:nickname/followers", ActivityPubController, :followers)
585 get("/users/:nickname/following", ActivityPubController, :following)
586 end
587
588 scope "/", Pleroma.Web.ActivityPub do
589 pipe_through(:activitypub)
590 post("/inbox", ActivityPubController, :inbox)
591 post("/users/:nickname/inbox", ActivityPubController, :inbox)
592 end
593
594 scope "/relay", Pleroma.Web.ActivityPub do
595 pipe_through(:ap_service_actor)
596
597 get("/", ActivityPubController, :relay)
598
599 scope [] do
600 pipe_through(:http_signature)
601 post("/inbox", ActivityPubController, :inbox)
602 end
603
604 get("/following", ActivityPubController, :relay_following)
605 get("/followers", ActivityPubController, :relay_followers)
606 end
607
608 scope "/internal/fetch", Pleroma.Web.ActivityPub do
609 pipe_through(:ap_service_actor)
610
611 get("/", ActivityPubController, :internal_fetch)
612 post("/inbox", ActivityPubController, :inbox)
613 end
614
615 scope "/.well-known", Pleroma.Web do
616 pipe_through(:well_known)
617
618 get("/host-meta", WebFinger.WebFingerController, :host_meta)
619 get("/webfinger", WebFinger.WebFingerController, :webfinger)
620 get("/nodeinfo", Nodeinfo.NodeinfoController, :schemas)
621 end
622
623 scope "/nodeinfo", Pleroma.Web do
624 get("/:version", Nodeinfo.NodeinfoController, :nodeinfo)
625 end
626
627 scope "/", Pleroma.Web do
628 pipe_through(:api)
629
630 get("/web/manifest.json", MastoFEController, :manifest)
631 end
632
633 scope "/", Pleroma.Web do
634 pipe_through(:mastodon_html)
635
636 get("/web/login", MastodonAPI.AuthController, :login)
637 delete("/auth/sign_out", MastodonAPI.AuthController, :logout)
638
639 post("/auth/password", MastodonAPI.AuthController, :password_reset)
640
641 get("/web/*path", MastoFEController, :index)
642 end
643
644 scope "/proxy/", Pleroma.Web.MediaProxy do
645 get("/:sig/:url", MediaProxyController, :remote)
646 get("/:sig/:url/:filename", MediaProxyController, :remote)
647 end
648
649 if Pleroma.Config.get(:env) == :dev do
650 scope "/dev" do
651 pipe_through([:mailbox_preview])
652
653 forward("/mailbox", Plug.Swoosh.MailboxPreview, base_path: "/dev/mailbox")
654 end
655 end
656
657 # Test-only routes needed to test action dispatching and plug chain execution
658 if Pleroma.Config.get(:env) == :test do
659 scope "/test/authenticated_api", Pleroma.Tests do
660 pipe_through(:authenticated_api)
661
662 for action <- [:skipped_oauth, :performed_oauth, :missed_oauth] do
663 get("/#{action}", OAuthTestController, action)
664 end
665 end
666 end
667
668 scope "/", Pleroma.Web.MongooseIM do
669 get("/user_exists", MongooseIMController, :user_exists)
670 get("/check_password", MongooseIMController, :check_password)
671 end
672
673 scope "/", Fallback do
674 get("/registration/:token", RedirectController, :registration_page)
675 get("/:maybe_nickname_or_id", RedirectController, :redirector_with_meta)
676 get("/api*path", RedirectController, :api_not_implemented)
677 get("/*path", RedirectController, :redirector)
678
679 options("/*path", RedirectController, :empty)
680 end
681 end