Merge branch 'develop' into 'remove-twitter-api'
[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", AdminAPIController, :status_show)
193 put("/statuses/:id", AdminAPIController, :status_update)
194 delete("/statuses/:id", AdminAPIController, :status_delete)
195 get("/statuses", AdminAPIController, :list_statuses)
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", EmojiAPIController, :import_from_filesystem)
220 get("/remote", EmojiAPIController, :remote)
221 post("/download", EmojiAPIController, :download)
222
223 post("/:name", EmojiAPIController, :create)
224 patch("/:name", EmojiAPIController, :update)
225 delete("/:name", EmojiAPIController, :delete)
226
227 post("/:name/files", EmojiAPIController, :add_file)
228 patch("/:name/files", EmojiAPIController, :update_file)
229 delete("/:name/files", EmojiAPIController, :delete_file)
230 end
231
232 # Pack info / downloading
233 scope "/packs" do
234 get("/", EmojiAPIController, :list)
235 get("/:name", EmojiAPIController, :show)
236 get("/:name/archive", EmojiAPIController, :archive)
237 end
238 end
239
240 scope "/", Pleroma.Web.TwitterAPI do
241 pipe_through(:pleroma_html)
242
243 post("/main/ostatus", UtilController, :remote_subscribe)
244 get("/ostatus_subscribe", RemoteFollowController, :follow)
245
246 post("/ostatus_subscribe", RemoteFollowController, :do_follow)
247 end
248
249 scope "/api/pleroma", Pleroma.Web.TwitterAPI do
250 pipe_through(:authenticated_api)
251
252 post("/change_email", UtilController, :change_email)
253 post("/change_password", UtilController, :change_password)
254 post("/delete_account", UtilController, :delete_account)
255 put("/notification_settings", UtilController, :update_notificaton_settings)
256 post("/disable_account", UtilController, :disable_account)
257
258 post("/blocks_import", UtilController, :blocks_import)
259 post("/follow_import", UtilController, :follow_import)
260 end
261
262 scope "/api/pleroma", Pleroma.Web.PleromaAPI do
263 pipe_through(:authenticated_api)
264
265 get("/accounts/mfa", TwoFactorAuthenticationController, :settings)
266 get("/accounts/mfa/backup_codes", TwoFactorAuthenticationController, :backup_codes)
267 get("/accounts/mfa/setup/:method", TwoFactorAuthenticationController, :setup)
268 post("/accounts/mfa/confirm/:method", TwoFactorAuthenticationController, :confirm)
269 delete("/accounts/mfa/:method", TwoFactorAuthenticationController, :disable)
270 end
271
272 scope "/oauth", Pleroma.Web.OAuth do
273 scope [] do
274 pipe_through(:oauth)
275 get("/authorize", OAuthController, :authorize)
276 end
277
278 post("/authorize", OAuthController, :create_authorization)
279 post("/token", OAuthController, :token_exchange)
280 post("/revoke", OAuthController, :token_revoke)
281 get("/registration_details", OAuthController, :registration_details)
282
283 post("/mfa/challenge", MFAController, :challenge)
284 post("/mfa/verify", MFAController, :verify, as: :mfa_verify)
285 get("/mfa", MFAController, :show)
286
287 scope [] do
288 pipe_through(:browser)
289
290 get("/prepare_request", OAuthController, :prepare_request)
291 get("/:provider", OAuthController, :request)
292 get("/:provider/callback", OAuthController, :callback)
293 post("/register", OAuthController, :register)
294 end
295 end
296
297 scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do
298 pipe_through(:api)
299
300 get("/statuses/:id/reactions/:emoji", PleromaAPIController, :emoji_reactions_by)
301 get("/statuses/:id/reactions", PleromaAPIController, :emoji_reactions_by)
302 end
303
304 scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do
305 scope [] do
306 pipe_through(:authenticated_api)
307
308 get("/conversations/:id/statuses", PleromaAPIController, :conversation_statuses)
309 get("/conversations/:id", PleromaAPIController, :conversation)
310 post("/conversations/read", PleromaAPIController, :mark_conversations_as_read)
311 end
312
313 scope [] do
314 pipe_through(:authenticated_api)
315
316 patch("/conversations/:id", PleromaAPIController, :update_conversation)
317 put("/statuses/:id/reactions/:emoji", PleromaAPIController, :react_with_emoji)
318 delete("/statuses/:id/reactions/:emoji", PleromaAPIController, :unreact_with_emoji)
319 post("/notifications/read", PleromaAPIController, :mark_notifications_as_read)
320
321 patch("/accounts/update_avatar", AccountController, :update_avatar)
322 patch("/accounts/update_banner", AccountController, :update_banner)
323 patch("/accounts/update_background", AccountController, :update_background)
324
325 get("/mascot", MascotController, :show)
326 put("/mascot", MascotController, :update)
327
328 post("/scrobble", ScrobbleController, :new_scrobble)
329 end
330
331 scope [] do
332 pipe_through(:api)
333 get("/accounts/:id/favourites", AccountController, :favourites)
334 end
335
336 scope [] do
337 pipe_through(:authenticated_api)
338
339 post("/accounts/:id/subscribe", AccountController, :subscribe)
340 post("/accounts/:id/unsubscribe", AccountController, :unsubscribe)
341 end
342
343 post("/accounts/confirmation_resend", AccountController, :confirmation_resend)
344 end
345
346 scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do
347 pipe_through(:api)
348 get("/accounts/:id/scrobbles", ScrobbleController, :user_scrobbles)
349 end
350
351 scope "/api/v1", Pleroma.Web.MastodonAPI do
352 pipe_through(:authenticated_api)
353
354 get("/accounts/verify_credentials", AccountController, :verify_credentials)
355 patch("/accounts/update_credentials", AccountController, :update_credentials)
356
357 get("/accounts/relationships", AccountController, :relationships)
358 get("/accounts/:id/lists", AccountController, :lists)
359 get("/accounts/:id/identity_proofs", AccountController, :identity_proofs)
360 get("/endorsements", AccountController, :endorsements)
361 get("/blocks", AccountController, :blocks)
362 get("/mutes", AccountController, :mutes)
363
364 post("/follows", AccountController, :follow_by_uri)
365 post("/accounts/:id/follow", AccountController, :follow)
366 post("/accounts/:id/unfollow", AccountController, :unfollow)
367 post("/accounts/:id/block", AccountController, :block)
368 post("/accounts/:id/unblock", AccountController, :unblock)
369 post("/accounts/:id/mute", AccountController, :mute)
370 post("/accounts/:id/unmute", AccountController, :unmute)
371
372 get("/apps/verify_credentials", AppController, :verify_credentials)
373
374 get("/conversations", ConversationController, :index)
375 post("/conversations/:id/read", ConversationController, :mark_as_read)
376
377 get("/domain_blocks", DomainBlockController, :index)
378 post("/domain_blocks", DomainBlockController, :create)
379 delete("/domain_blocks", DomainBlockController, :delete)
380
381 get("/filters", FilterController, :index)
382
383 post("/filters", FilterController, :create)
384 get("/filters/:id", FilterController, :show)
385 put("/filters/:id", FilterController, :update)
386 delete("/filters/:id", FilterController, :delete)
387
388 get("/follow_requests", FollowRequestController, :index)
389 post("/follow_requests/:id/authorize", FollowRequestController, :authorize)
390 post("/follow_requests/:id/reject", FollowRequestController, :reject)
391
392 get("/lists", ListController, :index)
393 get("/lists/:id", ListController, :show)
394 get("/lists/:id/accounts", ListController, :list_accounts)
395
396 delete("/lists/:id", ListController, :delete)
397 post("/lists", ListController, :create)
398 put("/lists/:id", ListController, :update)
399 post("/lists/:id/accounts", ListController, :add_to_list)
400 delete("/lists/:id/accounts", ListController, :remove_from_list)
401
402 get("/markers", MarkerController, :index)
403 post("/markers", MarkerController, :upsert)
404
405 post("/media", MediaController, :create)
406 put("/media/:id", MediaController, :update)
407
408 get("/notifications", NotificationController, :index)
409 get("/notifications/:id", NotificationController, :show)
410
411 post("/notifications/:id/dismiss", NotificationController, :dismiss)
412 post("/notifications/clear", NotificationController, :clear)
413 delete("/notifications/destroy_multiple", NotificationController, :destroy_multiple)
414 # Deprecated: was removed in Mastodon v3, use `/notifications/:id/dismiss` instead
415 post("/notifications/dismiss", NotificationController, :dismiss_via_body)
416
417 post("/polls/:id/votes", PollController, :vote)
418
419 post("/reports", ReportController, :create)
420
421 get("/scheduled_statuses", ScheduledActivityController, :index)
422 get("/scheduled_statuses/:id", ScheduledActivityController, :show)
423
424 put("/scheduled_statuses/:id", ScheduledActivityController, :update)
425 delete("/scheduled_statuses/:id", ScheduledActivityController, :delete)
426
427 # Unlike `GET /api/v1/accounts/:id/favourites`, demands authentication
428 get("/favourites", StatusController, :favourites)
429 get("/bookmarks", StatusController, :bookmarks)
430
431 post("/statuses", StatusController, :create)
432 delete("/statuses/:id", StatusController, :delete)
433 post("/statuses/:id/reblog", StatusController, :reblog)
434 post("/statuses/:id/unreblog", StatusController, :unreblog)
435 post("/statuses/:id/favourite", StatusController, :favourite)
436 post("/statuses/:id/unfavourite", StatusController, :unfavourite)
437 post("/statuses/:id/pin", StatusController, :pin)
438 post("/statuses/:id/unpin", StatusController, :unpin)
439 post("/statuses/:id/bookmark", StatusController, :bookmark)
440 post("/statuses/:id/unbookmark", StatusController, :unbookmark)
441 post("/statuses/:id/mute", StatusController, :mute_conversation)
442 post("/statuses/:id/unmute", StatusController, :unmute_conversation)
443
444 post("/push/subscription", SubscriptionController, :create)
445 get("/push/subscription", SubscriptionController, :show)
446 put("/push/subscription", SubscriptionController, :update)
447 delete("/push/subscription", SubscriptionController, :delete)
448
449 get("/suggestions", SuggestionController, :index)
450
451 get("/timelines/home", TimelineController, :home)
452 get("/timelines/direct", TimelineController, :direct)
453 get("/timelines/list/:list_id", TimelineController, :list)
454 end
455
456 scope "/api/web", Pleroma.Web do
457 pipe_through(:authenticated_api)
458
459 put("/settings", MastoFEController, :put_settings)
460 end
461
462 scope "/api/v1", Pleroma.Web.MastodonAPI do
463 pipe_through(:api)
464
465 get("/accounts/search", SearchController, :account_search)
466 get("/search", SearchController, :search)
467
468 get("/accounts/:id/statuses", AccountController, :statuses)
469 get("/accounts/:id/followers", AccountController, :followers)
470 get("/accounts/:id/following", AccountController, :following)
471 get("/accounts/:id", AccountController, :show)
472
473 post("/accounts", AccountController, :create)
474
475 get("/instance", InstanceController, :show)
476 get("/instance/peers", InstanceController, :peers)
477
478 post("/apps", AppController, :create)
479
480 get("/statuses", StatusController, :index)
481 get("/statuses/:id", StatusController, :show)
482 get("/statuses/:id/context", StatusController, :context)
483 get("/statuses/:id/card", StatusController, :card)
484 get("/statuses/:id/favourited_by", StatusController, :favourited_by)
485 get("/statuses/:id/reblogged_by", StatusController, :reblogged_by)
486
487 get("/custom_emojis", CustomEmojiController, :index)
488
489 get("/trends", MastodonAPIController, :empty_array)
490
491 get("/timelines/public", TimelineController, :public)
492 get("/timelines/tag/:tag", TimelineController, :hashtag)
493
494 get("/polls/:id", PollController, :show)
495 end
496
497 scope "/api/v2", Pleroma.Web.MastodonAPI do
498 pipe_through(:api)
499 get("/search", SearchController, :search2)
500 end
501
502 scope "/api", Pleroma.Web do
503 pipe_through(:config)
504
505 get("/pleroma/frontend_configurations", TwitterAPI.UtilController, :frontend_configurations)
506
507 # Deprecated
508 get("/statusnet/config", TwitterAPI.UtilController, :config)
509 end
510
511 scope "/api", Pleroma.Web do
512 pipe_through(:api)
513
514 get(
515 "/account/confirm_email/:user_id/:token",
516 TwitterAPI.Controller,
517 :confirm_email,
518 as: :confirm_email
519 )
520 end
521
522 scope "/api" do
523 pipe_through(:base_api)
524
525 get("/openapi", OpenApiSpex.Plug.RenderSpec, [])
526 end
527
528 scope "/api", Pleroma.Web, as: :authenticated_twitter_api do
529 pipe_through(:authenticated_api)
530
531 get("/oauth_tokens", TwitterAPI.Controller, :oauth_tokens)
532 delete("/oauth_tokens/:id", TwitterAPI.Controller, :revoke_token)
533
534 post(
535 "/qvitter/statuses/notifications/read",
536 TwitterAPI.Controller,
537 :mark_notifications_as_read
538 )
539 end
540
541 pipeline :ostatus do
542 plug(:accepts, ["html", "xml", "rss", "atom", "activity+json", "json"])
543 plug(Pleroma.Plugs.StaticFEPlug)
544 end
545
546 pipeline :oembed do
547 plug(:accepts, ["json", "xml"])
548 end
549
550 scope "/", Pleroma.Web do
551 pipe_through([:ostatus, :http_signature])
552
553 get("/objects/:uuid", OStatus.OStatusController, :object)
554 get("/activities/:uuid", OStatus.OStatusController, :activity)
555 get("/notice/:id", OStatus.OStatusController, :notice)
556 get("/notice/:id/embed_player", OStatus.OStatusController, :notice_player)
557
558 get("/users/:nickname/feed", Feed.UserController, :feed, as: :user_feed)
559 get("/users/:nickname", Feed.UserController, :feed_redirect, as: :user_feed)
560
561 get("/tags/:tag", Feed.TagController, :feed, as: :tag_feed)
562 end
563
564 scope "/", Pleroma.Web do
565 pipe_through(:browser)
566 get("/mailer/unsubscribe/:token", Mailer.SubscriptionController, :unsubscribe)
567 end
568
569 scope "/", Pleroma.Web.ActivityPub do
570 # XXX: not really ostatus
571 pipe_through(:ostatus)
572
573 get("/users/:nickname/outbox", ActivityPubController, :outbox)
574 end
575
576 pipeline :ap_service_actor do
577 plug(:accepts, ["activity+json", "json"])
578 end
579
580 # Server to Server (S2S) AP interactions
581 pipeline :activitypub do
582 plug(:ap_service_actor)
583 plug(:http_signature)
584 end
585
586 # Client to Server (C2S) AP interactions
587 pipeline :activitypub_client do
588 plug(:ap_service_actor)
589 plug(:fetch_session)
590 plug(:authenticate)
591 plug(:after_auth)
592 end
593
594 scope "/", Pleroma.Web.ActivityPub do
595 pipe_through([:activitypub_client])
596
597 get("/api/ap/whoami", ActivityPubController, :whoami)
598 get("/users/:nickname/inbox", ActivityPubController, :read_inbox)
599
600 post("/users/:nickname/outbox", ActivityPubController, :update_outbox)
601 post("/api/ap/upload_media", ActivityPubController, :upload_media)
602
603 # The following two are S2S as well, see `ActivityPub.fetch_follow_information_for_user/1`:
604 get("/users/:nickname/followers", ActivityPubController, :followers)
605 get("/users/:nickname/following", ActivityPubController, :following)
606 end
607
608 scope "/", Pleroma.Web.ActivityPub do
609 pipe_through(:activitypub)
610 post("/inbox", ActivityPubController, :inbox)
611 post("/users/:nickname/inbox", ActivityPubController, :inbox)
612 end
613
614 scope "/relay", Pleroma.Web.ActivityPub do
615 pipe_through(:ap_service_actor)
616
617 get("/", ActivityPubController, :relay)
618
619 scope [] do
620 pipe_through(:http_signature)
621 post("/inbox", ActivityPubController, :inbox)
622 end
623
624 get("/following", ActivityPubController, :relay_following)
625 get("/followers", ActivityPubController, :relay_followers)
626 end
627
628 scope "/internal/fetch", Pleroma.Web.ActivityPub do
629 pipe_through(:ap_service_actor)
630
631 get("/", ActivityPubController, :internal_fetch)
632 post("/inbox", ActivityPubController, :inbox)
633 end
634
635 scope "/.well-known", Pleroma.Web do
636 pipe_through(:well_known)
637
638 get("/host-meta", WebFinger.WebFingerController, :host_meta)
639 get("/webfinger", WebFinger.WebFingerController, :webfinger)
640 get("/nodeinfo", Nodeinfo.NodeinfoController, :schemas)
641 end
642
643 scope "/nodeinfo", Pleroma.Web do
644 get("/:version", Nodeinfo.NodeinfoController, :nodeinfo)
645 end
646
647 scope "/", Pleroma.Web do
648 pipe_through(:api)
649
650 get("/web/manifest.json", MastoFEController, :manifest)
651 end
652
653 scope "/", Pleroma.Web do
654 pipe_through(:mastodon_html)
655
656 get("/web/login", MastodonAPI.AuthController, :login)
657 delete("/auth/sign_out", MastodonAPI.AuthController, :logout)
658
659 post("/auth/password", MastodonAPI.AuthController, :password_reset)
660
661 get("/web/*path", MastoFEController, :index)
662 end
663
664 scope "/proxy/", Pleroma.Web.MediaProxy do
665 get("/:sig/:url", MediaProxyController, :remote)
666 get("/:sig/:url/:filename", MediaProxyController, :remote)
667 end
668
669 if Pleroma.Config.get(:env) == :dev do
670 scope "/dev" do
671 pipe_through([:mailbox_preview])
672
673 forward("/mailbox", Plug.Swoosh.MailboxPreview, base_path: "/dev/mailbox")
674 end
675 end
676
677 # Test-only routes needed to test action dispatching and plug chain execution
678 if Pleroma.Config.get(:env) == :test do
679 @test_actions [
680 :do_oauth_check,
681 :fallback_oauth_check,
682 :skip_oauth_check,
683 :fallback_oauth_skip_publicity_check,
684 :skip_oauth_skip_publicity_check,
685 :missing_oauth_check_definition
686 ]
687
688 scope "/test/api", Pleroma.Tests do
689 pipe_through(:api)
690
691 for action <- @test_actions do
692 get("/#{action}", AuthTestController, action)
693 end
694 end
695
696 scope "/test/authenticated_api", Pleroma.Tests do
697 pipe_through(:authenticated_api)
698
699 for action <- @test_actions do
700 get("/#{action}", AuthTestController, action)
701 end
702 end
703 end
704
705 scope "/", Pleroma.Web.MongooseIM do
706 get("/user_exists", MongooseIMController, :user_exists)
707 get("/check_password", MongooseIMController, :check_password)
708 end
709
710 scope "/", Fallback do
711 get("/registration/:token", RedirectController, :registration_page)
712 get("/:maybe_nickname_or_id", RedirectController, :redirector_with_meta)
713 get("/api*path", RedirectController, :api_not_implemented)
714 get("/*path", RedirectController, :redirector)
715
716 options("/*path", RedirectController, :empty)
717 end
718 end