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