Merge branch 'bugfix/following-fix-status-code' into 'develop'
[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 get("/conversations/:id/statuses", PleromaAPIController, :conversation_statuses)
279 get("/conversations/:id", PleromaAPIController, :conversation)
280 post("/conversations/read", PleromaAPIController, :read_conversations)
281 end
282
283 scope [] do
284 pipe_through(:authenticated_api)
285
286 patch("/conversations/:id", PleromaAPIController, :update_conversation)
287 put("/statuses/:id/reactions/:emoji", PleromaAPIController, :react_with_emoji)
288 delete("/statuses/:id/reactions/:emoji", PleromaAPIController, :unreact_with_emoji)
289 post("/notifications/read", PleromaAPIController, :read_notification)
290
291 patch("/accounts/update_avatar", AccountController, :update_avatar)
292 patch("/accounts/update_banner", AccountController, :update_banner)
293 patch("/accounts/update_background", AccountController, :update_background)
294
295 get("/mascot", MascotController, :show)
296 put("/mascot", MascotController, :update)
297
298 post("/scrobble", ScrobbleController, :new_scrobble)
299 end
300
301 scope [] do
302 pipe_through(:api)
303 get("/accounts/:id/favourites", AccountController, :favourites)
304 end
305
306 scope [] do
307 pipe_through(:authenticated_api)
308
309 post("/accounts/:id/subscribe", AccountController, :subscribe)
310 post("/accounts/:id/unsubscribe", AccountController, :unsubscribe)
311 end
312
313 post("/accounts/confirmation_resend", AccountController, :confirmation_resend)
314 end
315
316 scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do
317 pipe_through(:api)
318 get("/accounts/:id/scrobbles", ScrobbleController, :user_scrobbles)
319 end
320
321 scope "/api/v1", Pleroma.Web.MastodonAPI do
322 pipe_through(:authenticated_api)
323
324 get("/accounts/verify_credentials", AccountController, :verify_credentials)
325
326 get("/accounts/relationships", AccountController, :relationships)
327
328 get("/accounts/:id/lists", AccountController, :lists)
329 get("/accounts/:id/identity_proofs", AccountController, :identity_proofs)
330
331 get("/follow_requests", FollowRequestController, :index)
332 get("/blocks", AccountController, :blocks)
333 get("/mutes", AccountController, :mutes)
334
335 get("/timelines/home", TimelineController, :home)
336 get("/timelines/direct", TimelineController, :direct)
337
338 get("/favourites", StatusController, :favourites)
339 get("/bookmarks", StatusController, :bookmarks)
340
341 get("/notifications", NotificationController, :index)
342 get("/notifications/:id", NotificationController, :show)
343 post("/notifications/:id/dismiss", NotificationController, :dismiss)
344 post("/notifications/clear", NotificationController, :clear)
345 delete("/notifications/destroy_multiple", NotificationController, :destroy_multiple)
346 # Deprecated: was removed in Mastodon v3, use `/notifications/:id/dismiss` instead
347 post("/notifications/dismiss", NotificationController, :dismiss)
348
349 get("/scheduled_statuses", ScheduledActivityController, :index)
350 get("/scheduled_statuses/:id", ScheduledActivityController, :show)
351
352 get("/lists", ListController, :index)
353 get("/lists/:id", ListController, :show)
354 get("/lists/:id/accounts", ListController, :list_accounts)
355
356 get("/domain_blocks", DomainBlockController, :index)
357
358 get("/filters", FilterController, :index)
359
360 get("/suggestions", SuggestionController, :index)
361
362 get("/conversations", ConversationController, :index)
363 post("/conversations/:id/read", ConversationController, :read)
364
365 get("/endorsements", AccountController, :endorsements)
366
367 patch("/accounts/update_credentials", AccountController, :update_credentials)
368
369 post("/statuses", StatusController, :create)
370 delete("/statuses/:id", StatusController, :delete)
371
372 post("/statuses/:id/reblog", StatusController, :reblog)
373 post("/statuses/:id/unreblog", StatusController, :unreblog)
374 post("/statuses/:id/favourite", StatusController, :favourite)
375 post("/statuses/:id/unfavourite", StatusController, :unfavourite)
376 post("/statuses/:id/pin", StatusController, :pin)
377 post("/statuses/:id/unpin", StatusController, :unpin)
378 post("/statuses/:id/bookmark", StatusController, :bookmark)
379 post("/statuses/:id/unbookmark", StatusController, :unbookmark)
380 post("/statuses/:id/mute", StatusController, :mute_conversation)
381 post("/statuses/:id/unmute", StatusController, :unmute_conversation)
382
383 put("/scheduled_statuses/:id", ScheduledActivityController, :update)
384 delete("/scheduled_statuses/:id", ScheduledActivityController, :delete)
385
386 post("/polls/:id/votes", PollController, :vote)
387
388 post("/media", MediaController, :create)
389 put("/media/:id", MediaController, :update)
390
391 delete("/lists/:id", ListController, :delete)
392 post("/lists", ListController, :create)
393 put("/lists/:id", ListController, :update)
394
395 post("/lists/:id/accounts", ListController, :add_to_list)
396 delete("/lists/:id/accounts", ListController, :remove_from_list)
397
398 post("/filters", FilterController, :create)
399 get("/filters/:id", FilterController, :show)
400 put("/filters/:id", FilterController, :update)
401 delete("/filters/:id", FilterController, :delete)
402
403 post("/reports", ReportController, :create)
404
405 post("/follows", AccountController, :follows)
406 post("/accounts/:id/follow", AccountController, :follow)
407 post("/accounts/:id/unfollow", AccountController, :unfollow)
408 post("/accounts/:id/block", AccountController, :block)
409 post("/accounts/:id/unblock", AccountController, :unblock)
410 post("/accounts/:id/mute", AccountController, :mute)
411 post("/accounts/:id/unmute", AccountController, :unmute)
412
413 post("/follow_requests/:id/authorize", FollowRequestController, :authorize)
414 post("/follow_requests/:id/reject", FollowRequestController, :reject)
415
416 post("/domain_blocks", DomainBlockController, :create)
417 delete("/domain_blocks", DomainBlockController, :delete)
418
419 post("/push/subscription", SubscriptionController, :create)
420 get("/push/subscription", SubscriptionController, :get)
421 put("/push/subscription", SubscriptionController, :update)
422 delete("/push/subscription", SubscriptionController, :delete)
423
424 get("/markers", MarkerController, :index)
425 post("/markers", MarkerController, :upsert)
426 end
427
428 scope "/api/web", Pleroma.Web do
429 pipe_through(:authenticated_api)
430
431 put("/settings", MastoFEController, :put_settings)
432 end
433
434 scope "/api/v1", Pleroma.Web.MastodonAPI do
435 pipe_through(:api)
436
437 post("/accounts", AccountController, :create)
438 get("/accounts/search", SearchController, :account_search)
439
440 get("/instance", InstanceController, :show)
441 get("/instance/peers", InstanceController, :peers)
442
443 post("/apps", AppController, :create)
444 get("/apps/verify_credentials", AppController, :verify_credentials)
445
446 get("/statuses/:id/card", StatusController, :card)
447 get("/statuses/:id/favourited_by", StatusController, :favourited_by)
448 get("/statuses/:id/reblogged_by", StatusController, :reblogged_by)
449
450 get("/custom_emojis", CustomEmojiController, :index)
451
452 get("/trends", MastodonAPIController, :empty_array)
453
454 get("/timelines/public", TimelineController, :public)
455 get("/timelines/tag/:tag", TimelineController, :hashtag)
456 get("/timelines/list/:list_id", TimelineController, :list)
457
458 get("/statuses", StatusController, :index)
459 get("/statuses/:id", StatusController, :show)
460 get("/statuses/:id/context", StatusController, :context)
461
462 get("/polls/:id", PollController, :show)
463
464 get("/accounts/:id/statuses", AccountController, :statuses)
465 get("/accounts/:id/followers", AccountController, :followers)
466 get("/accounts/:id/following", AccountController, :following)
467 get("/accounts/:id", AccountController, :show)
468
469 get("/search", SearchController, :search)
470 end
471
472 scope "/api/v2", Pleroma.Web.MastodonAPI do
473 pipe_through(:api)
474 get("/search", SearchController, :search2)
475 end
476
477 scope "/api", Pleroma.Web do
478 pipe_through(:config)
479
480 get("/help/test", TwitterAPI.UtilController, :help_test)
481 post("/help/test", TwitterAPI.UtilController, :help_test)
482 get("/statusnet/config", TwitterAPI.UtilController, :config)
483 get("/statusnet/version", TwitterAPI.UtilController, :version)
484 get("/pleroma/frontend_configurations", TwitterAPI.UtilController, :frontend_configurations)
485 end
486
487 scope "/api", Pleroma.Web do
488 pipe_through(:api)
489
490 get(
491 "/account/confirm_email/:user_id/:token",
492 TwitterAPI.Controller,
493 :confirm_email,
494 as: :confirm_email
495 )
496 end
497
498 scope "/api" do
499 pipe_through(:base_api)
500
501 get("/openapi", OpenApiSpex.Plug.RenderSpec, [])
502 end
503
504 scope "/api", Pleroma.Web, as: :authenticated_twitter_api do
505 pipe_through(:authenticated_api)
506
507 get("/oauth_tokens", TwitterAPI.Controller, :oauth_tokens)
508 delete("/oauth_tokens/:id", TwitterAPI.Controller, :revoke_token)
509
510 post("/qvitter/statuses/notifications/read", TwitterAPI.Controller, :notifications_read)
511 end
512
513 pipeline :ostatus do
514 plug(:accepts, ["html", "xml", "rss", "atom", "activity+json", "json"])
515 plug(Pleroma.Plugs.StaticFEPlug)
516 end
517
518 pipeline :oembed do
519 plug(:accepts, ["json", "xml"])
520 end
521
522 scope "/", Pleroma.Web do
523 pipe_through([:ostatus, :http_signature])
524
525 get("/objects/:uuid", OStatus.OStatusController, :object)
526 get("/activities/:uuid", OStatus.OStatusController, :activity)
527 get("/notice/:id", OStatus.OStatusController, :notice)
528 get("/notice/:id/embed_player", OStatus.OStatusController, :notice_player)
529
530 get("/users/:nickname/feed", Feed.UserController, :feed, as: :user_feed)
531 get("/users/:nickname", Feed.UserController, :feed_redirect, as: :user_feed)
532
533 get("/tags/:tag", Feed.TagController, :feed, as: :tag_feed)
534 end
535
536 scope "/", Pleroma.Web do
537 pipe_through(:browser)
538 get("/mailer/unsubscribe/:token", Mailer.SubscriptionController, :unsubscribe)
539 end
540
541 scope "/", Pleroma.Web.ActivityPub do
542 # XXX: not really ostatus
543 pipe_through(:ostatus)
544
545 get("/users/:nickname/outbox", ActivityPubController, :outbox)
546 end
547
548 pipeline :ap_service_actor do
549 plug(:accepts, ["activity+json", "json"])
550 end
551
552 # Server to Server (S2S) AP interactions
553 pipeline :activitypub do
554 plug(:ap_service_actor)
555 plug(:http_signature)
556 end
557
558 # Client to Server (C2S) AP interactions
559 pipeline :activitypub_client do
560 plug(:ap_service_actor)
561 plug(:fetch_session)
562 plug(:authenticate)
563 plug(:after_auth)
564 end
565
566 scope "/", Pleroma.Web.ActivityPub do
567 pipe_through([:activitypub_client])
568
569 get("/api/ap/whoami", ActivityPubController, :whoami)
570 get("/users/:nickname/inbox", ActivityPubController, :read_inbox)
571
572 post("/users/:nickname/outbox", ActivityPubController, :update_outbox)
573 post("/api/ap/upload_media", ActivityPubController, :upload_media)
574
575 get("/users/:nickname/followers", ActivityPubController, :followers)
576 get("/users/:nickname/following", ActivityPubController, :following)
577 end
578
579 scope "/", Pleroma.Web.ActivityPub do
580 pipe_through(:activitypub)
581 post("/inbox", ActivityPubController, :inbox)
582 post("/users/:nickname/inbox", ActivityPubController, :inbox)
583 end
584
585 scope "/relay", Pleroma.Web.ActivityPub do
586 pipe_through(:ap_service_actor)
587
588 get("/", ActivityPubController, :relay)
589
590 scope [] do
591 pipe_through(:http_signature)
592 post("/inbox", ActivityPubController, :inbox)
593 end
594
595 get("/following", ActivityPubController, :relay_following)
596 get("/followers", ActivityPubController, :relay_followers)
597 end
598
599 scope "/internal/fetch", Pleroma.Web.ActivityPub do
600 pipe_through(:ap_service_actor)
601
602 get("/", ActivityPubController, :internal_fetch)
603 post("/inbox", ActivityPubController, :inbox)
604 end
605
606 scope "/.well-known", Pleroma.Web do
607 pipe_through(:well_known)
608
609 get("/host-meta", WebFinger.WebFingerController, :host_meta)
610 get("/webfinger", WebFinger.WebFingerController, :webfinger)
611 get("/nodeinfo", Nodeinfo.NodeinfoController, :schemas)
612 end
613
614 scope "/nodeinfo", Pleroma.Web do
615 get("/:version", Nodeinfo.NodeinfoController, :nodeinfo)
616 end
617
618 scope "/", Pleroma.Web do
619 pipe_through(:api)
620
621 get("/web/manifest.json", MastoFEController, :manifest)
622 end
623
624 scope "/", Pleroma.Web do
625 pipe_through(:mastodon_html)
626
627 get("/web/login", MastodonAPI.AuthController, :login)
628 delete("/auth/sign_out", MastodonAPI.AuthController, :logout)
629
630 post("/auth/password", MastodonAPI.AuthController, :password_reset)
631
632 get("/web/*path", MastoFEController, :index)
633 end
634
635 scope "/proxy/", Pleroma.Web.MediaProxy do
636 get("/:sig/:url", MediaProxyController, :remote)
637 get("/:sig/:url/:filename", MediaProxyController, :remote)
638 end
639
640 if Pleroma.Config.get(:env) == :dev do
641 scope "/dev" do
642 pipe_through([:mailbox_preview])
643
644 forward("/mailbox", Plug.Swoosh.MailboxPreview, base_path: "/dev/mailbox")
645 end
646 end
647
648 # Test-only routes needed to test action dispatching and plug chain execution
649 if Pleroma.Config.get(:env) == :test do
650 scope "/test/authenticated_api", Pleroma.Tests do
651 pipe_through(:authenticated_api)
652
653 for action <- [:skipped_oauth, :performed_oauth, :missed_oauth] do
654 get("/#{action}", OAuthTestController, action)
655 end
656 end
657 end
658
659 scope "/", Pleroma.Web.MongooseIM do
660 get("/user_exists", MongooseIMController, :user_exists)
661 get("/check_password", MongooseIMController, :check_password)
662 end
663
664 scope "/", Fallback do
665 get("/registration/:token", RedirectController, :registration_page)
666 get("/:maybe_nickname_or_id", RedirectController, :redirector_with_meta)
667 get("/api*path", RedirectController, :api_not_implemented)
668 get("/*path", RedirectController, :redirector)
669
670 options("/*path", RedirectController, :empty)
671 end
672 end