Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into media-preview-proxy
[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 patch("/users/approve", AdminAPIController, :user_approve)
142 put("/users/tag", AdminAPIController, :tag_users)
143 delete("/users/tag", AdminAPIController, :untag_users)
144
145 get("/users/:nickname/permission_group", AdminAPIController, :right_get)
146 get("/users/:nickname/permission_group/:permission_group", AdminAPIController, :right_get)
147
148 post("/users/:nickname/permission_group/:permission_group", AdminAPIController, :right_add)
149
150 delete(
151 "/users/:nickname/permission_group/:permission_group",
152 AdminAPIController,
153 :right_delete
154 )
155
156 post("/users/permission_group/:permission_group", AdminAPIController, :right_add_multiple)
157
158 delete(
159 "/users/permission_group/:permission_group",
160 AdminAPIController,
161 :right_delete_multiple
162 )
163
164 get("/relay", RelayController, :index)
165 post("/relay", RelayController, :follow)
166 delete("/relay", RelayController, :unfollow)
167
168 post("/users/invite_token", InviteController, :create)
169 get("/users/invites", InviteController, :index)
170 post("/users/revoke_invite", InviteController, :revoke)
171 post("/users/email_invite", InviteController, :email)
172
173 get("/users/:nickname/password_reset", AdminAPIController, :get_password_reset)
174 patch("/users/force_password_reset", AdminAPIController, :force_password_reset)
175 get("/users/:nickname/credentials", AdminAPIController, :show_user_credentials)
176 patch("/users/:nickname/credentials", AdminAPIController, :update_user_credentials)
177
178 get("/users", AdminAPIController, :list_users)
179 get("/users/:nickname", AdminAPIController, :user_show)
180 get("/users/:nickname/statuses", AdminAPIController, :list_user_statuses)
181
182 get("/instances/:instance/statuses", AdminAPIController, :list_instance_statuses)
183
184 patch("/users/confirm_email", AdminAPIController, :confirm_email)
185 patch("/users/resend_confirmation_email", AdminAPIController, :resend_confirmation_email)
186
187 get("/reports", ReportController, :index)
188 get("/reports/:id", ReportController, :show)
189 patch("/reports", ReportController, :update)
190 post("/reports/:id/notes", ReportController, :notes_create)
191 delete("/reports/:report_id/notes/:id", ReportController, :notes_delete)
192
193 get("/statuses/:id", StatusController, :show)
194 put("/statuses/:id", StatusController, :update)
195 delete("/statuses/:id", StatusController, :delete)
196 get("/statuses", StatusController, :index)
197
198 get("/config", ConfigController, :show)
199 post("/config", ConfigController, :update)
200 get("/config/descriptions", ConfigController, :descriptions)
201 get("/need_reboot", AdminAPIController, :need_reboot)
202 get("/restart", AdminAPIController, :restart)
203
204 get("/moderation_log", AdminAPIController, :list_log)
205
206 post("/reload_emoji", AdminAPIController, :reload_emoji)
207 get("/stats", AdminAPIController, :stats)
208
209 get("/oauth_app", OAuthAppController, :index)
210 post("/oauth_app", OAuthAppController, :create)
211 patch("/oauth_app/:id", OAuthAppController, :update)
212 delete("/oauth_app/:id", OAuthAppController, :delete)
213
214 get("/media_proxy_caches", MediaProxyCacheController, :index)
215 post("/media_proxy_caches/delete", MediaProxyCacheController, :delete)
216 post("/media_proxy_caches/purge", MediaProxyCacheController, :purge)
217 end
218
219 scope "/api/pleroma/emoji", Pleroma.Web.PleromaAPI do
220 # Modifying packs
221 scope "/packs" do
222 pipe_through(:admin_api)
223
224 get("/import", EmojiPackController, :import_from_filesystem)
225 get("/remote", EmojiPackController, :remote)
226 post("/download", EmojiPackController, :download)
227
228 post("/:name", EmojiPackController, :create)
229 patch("/:name", EmojiPackController, :update)
230 delete("/:name", EmojiPackController, :delete)
231
232 post("/:name/files", EmojiPackController, :add_file)
233 patch("/:name/files", EmojiPackController, :update_file)
234 delete("/:name/files", EmojiPackController, :delete_file)
235 end
236
237 # Pack info / downloading
238 scope "/packs" do
239 pipe_through(:api)
240 get("/", EmojiPackController, :index)
241 get("/:name", EmojiPackController, :show)
242 get("/:name/archive", EmojiPackController, :archive)
243 end
244 end
245
246 scope "/", Pleroma.Web.TwitterAPI do
247 pipe_through(:pleroma_html)
248
249 post("/main/ostatus", UtilController, :remote_subscribe)
250 get("/ostatus_subscribe", RemoteFollowController, :follow)
251
252 post("/ostatus_subscribe", RemoteFollowController, :do_follow)
253 end
254
255 scope "/api/pleroma", Pleroma.Web.TwitterAPI do
256 pipe_through(:authenticated_api)
257
258 post("/change_email", UtilController, :change_email)
259 post("/change_password", UtilController, :change_password)
260 post("/delete_account", UtilController, :delete_account)
261 put("/notification_settings", UtilController, :update_notificaton_settings)
262 post("/disable_account", UtilController, :disable_account)
263
264 post("/blocks_import", UtilController, :blocks_import)
265 post("/follow_import", UtilController, :follow_import)
266 end
267
268 scope "/api/pleroma", Pleroma.Web.PleromaAPI do
269 pipe_through(:authenticated_api)
270
271 get("/accounts/mfa", TwoFactorAuthenticationController, :settings)
272 get("/accounts/mfa/backup_codes", TwoFactorAuthenticationController, :backup_codes)
273 get("/accounts/mfa/setup/:method", TwoFactorAuthenticationController, :setup)
274 post("/accounts/mfa/confirm/:method", TwoFactorAuthenticationController, :confirm)
275 delete("/accounts/mfa/:method", TwoFactorAuthenticationController, :disable)
276 end
277
278 scope "/oauth", Pleroma.Web.OAuth do
279 scope [] do
280 pipe_through(:oauth)
281 get("/authorize", OAuthController, :authorize)
282 end
283
284 post("/authorize", OAuthController, :create_authorization)
285 post("/token", OAuthController, :token_exchange)
286 post("/revoke", OAuthController, :token_revoke)
287 get("/registration_details", OAuthController, :registration_details)
288
289 post("/mfa/challenge", MFAController, :challenge)
290 post("/mfa/verify", MFAController, :verify, as: :mfa_verify)
291 get("/mfa", MFAController, :show)
292
293 scope [] do
294 pipe_through(:browser)
295
296 get("/prepare_request", OAuthController, :prepare_request)
297 get("/:provider", OAuthController, :request)
298 get("/:provider/callback", OAuthController, :callback)
299 post("/register", OAuthController, :register)
300 end
301 end
302
303 scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do
304 pipe_through(:api)
305
306 get("/statuses/:id/reactions/:emoji", EmojiReactionController, :index)
307 get("/statuses/:id/reactions", EmojiReactionController, :index)
308 end
309
310 scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do
311 scope [] do
312 pipe_through(:authenticated_api)
313
314 post("/chats/by-account-id/:id", ChatController, :create)
315 get("/chats", ChatController, :index)
316 get("/chats/:id", ChatController, :show)
317 get("/chats/:id/messages", ChatController, :messages)
318 post("/chats/:id/messages", ChatController, :post_chat_message)
319 delete("/chats/:id/messages/:message_id", ChatController, :delete_message)
320 post("/chats/:id/read", ChatController, :mark_as_read)
321 post("/chats/:id/messages/:message_id/read", ChatController, :mark_message_as_read)
322
323 get("/conversations/:id/statuses", ConversationController, :statuses)
324 get("/conversations/:id", ConversationController, :show)
325 post("/conversations/read", ConversationController, :mark_as_read)
326 patch("/conversations/:id", ConversationController, :update)
327
328 put("/statuses/:id/reactions/:emoji", EmojiReactionController, :create)
329 delete("/statuses/:id/reactions/:emoji", EmojiReactionController, :delete)
330 post("/notifications/read", NotificationController, :mark_as_read)
331
332 get("/mascot", MascotController, :show)
333 put("/mascot", MascotController, :update)
334
335 post("/scrobble", ScrobbleController, :create)
336 end
337
338 scope [] do
339 pipe_through(:api)
340 get("/accounts/:id/favourites", AccountController, :favourites)
341 end
342
343 scope [] do
344 pipe_through(:authenticated_api)
345
346 post("/accounts/:id/subscribe", AccountController, :subscribe)
347 post("/accounts/:id/unsubscribe", AccountController, :unsubscribe)
348 end
349
350 post("/accounts/confirmation_resend", AccountController, :confirmation_resend)
351 end
352
353 scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do
354 pipe_through(:api)
355 get("/accounts/:id/scrobbles", ScrobbleController, :index)
356 end
357
358 scope "/api/v1", Pleroma.Web.MastodonAPI do
359 pipe_through(:authenticated_api)
360
361 get("/accounts/verify_credentials", AccountController, :verify_credentials)
362 patch("/accounts/update_credentials", AccountController, :update_credentials)
363
364 get("/accounts/relationships", AccountController, :relationships)
365 get("/accounts/:id/lists", AccountController, :lists)
366 get("/accounts/:id/identity_proofs", AccountController, :identity_proofs)
367 get("/endorsements", AccountController, :endorsements)
368 get("/blocks", AccountController, :blocks)
369 get("/mutes", AccountController, :mutes)
370
371 post("/follows", AccountController, :follow_by_uri)
372 post("/accounts/:id/follow", AccountController, :follow)
373 post("/accounts/:id/unfollow", AccountController, :unfollow)
374 post("/accounts/:id/block", AccountController, :block)
375 post("/accounts/:id/unblock", AccountController, :unblock)
376 post("/accounts/:id/mute", AccountController, :mute)
377 post("/accounts/:id/unmute", AccountController, :unmute)
378
379 get("/apps/verify_credentials", AppController, :verify_credentials)
380
381 get("/conversations", ConversationController, :index)
382 post("/conversations/:id/read", ConversationController, :mark_as_read)
383
384 get("/domain_blocks", DomainBlockController, :index)
385 post("/domain_blocks", DomainBlockController, :create)
386 delete("/domain_blocks", DomainBlockController, :delete)
387
388 get("/filters", FilterController, :index)
389
390 post("/filters", FilterController, :create)
391 get("/filters/:id", FilterController, :show)
392 put("/filters/:id", FilterController, :update)
393 delete("/filters/:id", FilterController, :delete)
394
395 get("/follow_requests", FollowRequestController, :index)
396 post("/follow_requests/:id/authorize", FollowRequestController, :authorize)
397 post("/follow_requests/:id/reject", FollowRequestController, :reject)
398
399 get("/lists", ListController, :index)
400 get("/lists/:id", ListController, :show)
401 get("/lists/:id/accounts", ListController, :list_accounts)
402
403 delete("/lists/:id", ListController, :delete)
404 post("/lists", ListController, :create)
405 put("/lists/:id", ListController, :update)
406 post("/lists/:id/accounts", ListController, :add_to_list)
407 delete("/lists/:id/accounts", ListController, :remove_from_list)
408
409 get("/markers", MarkerController, :index)
410 post("/markers", MarkerController, :upsert)
411
412 post("/media", MediaController, :create)
413 get("/media/:id", MediaController, :show)
414 put("/media/:id", MediaController, :update)
415
416 get("/notifications", NotificationController, :index)
417 get("/notifications/:id", NotificationController, :show)
418
419 post("/notifications/:id/dismiss", NotificationController, :dismiss)
420 post("/notifications/clear", NotificationController, :clear)
421 delete("/notifications/destroy_multiple", NotificationController, :destroy_multiple)
422 # Deprecated: was removed in Mastodon v3, use `/notifications/:id/dismiss` instead
423 post("/notifications/dismiss", NotificationController, :dismiss_via_body)
424
425 post("/polls/:id/votes", PollController, :vote)
426
427 post("/reports", ReportController, :create)
428
429 get("/scheduled_statuses", ScheduledActivityController, :index)
430 get("/scheduled_statuses/:id", ScheduledActivityController, :show)
431
432 put("/scheduled_statuses/:id", ScheduledActivityController, :update)
433 delete("/scheduled_statuses/:id", ScheduledActivityController, :delete)
434
435 # Unlike `GET /api/v1/accounts/:id/favourites`, demands authentication
436 get("/favourites", StatusController, :favourites)
437 get("/bookmarks", StatusController, :bookmarks)
438
439 post("/statuses", StatusController, :create)
440 delete("/statuses/:id", StatusController, :delete)
441 post("/statuses/:id/reblog", StatusController, :reblog)
442 post("/statuses/:id/unreblog", StatusController, :unreblog)
443 post("/statuses/:id/favourite", StatusController, :favourite)
444 post("/statuses/:id/unfavourite", StatusController, :unfavourite)
445 post("/statuses/:id/pin", StatusController, :pin)
446 post("/statuses/:id/unpin", StatusController, :unpin)
447 post("/statuses/:id/bookmark", StatusController, :bookmark)
448 post("/statuses/:id/unbookmark", StatusController, :unbookmark)
449 post("/statuses/:id/mute", StatusController, :mute_conversation)
450 post("/statuses/:id/unmute", StatusController, :unmute_conversation)
451
452 post("/push/subscription", SubscriptionController, :create)
453 get("/push/subscription", SubscriptionController, :show)
454 put("/push/subscription", SubscriptionController, :update)
455 delete("/push/subscription", SubscriptionController, :delete)
456
457 get("/suggestions", SuggestionController, :index)
458
459 get("/timelines/home", TimelineController, :home)
460 get("/timelines/direct", TimelineController, :direct)
461 get("/timelines/list/:list_id", TimelineController, :list)
462 end
463
464 scope "/api/web", Pleroma.Web do
465 pipe_through(:authenticated_api)
466
467 # Backend-obscure settings blob for MastoFE, don't parse/reuse elsewhere
468 put("/settings", MastoFEController, :put_settings)
469 end
470
471 scope "/api/v1", Pleroma.Web.MastodonAPI do
472 pipe_through(:api)
473
474 get("/accounts/search", SearchController, :account_search)
475 get("/search", SearchController, :search)
476
477 get("/accounts/:id/statuses", AccountController, :statuses)
478 get("/accounts/:id/followers", AccountController, :followers)
479 get("/accounts/:id/following", AccountController, :following)
480 get("/accounts/:id", AccountController, :show)
481
482 post("/accounts", AccountController, :create)
483
484 get("/instance", InstanceController, :show)
485 get("/instance/peers", InstanceController, :peers)
486
487 post("/apps", AppController, :create)
488
489 get("/statuses", StatusController, :index)
490 get("/statuses/:id", StatusController, :show)
491 get("/statuses/:id/context", StatusController, :context)
492 get("/statuses/:id/card", StatusController, :card)
493 get("/statuses/:id/favourited_by", StatusController, :favourited_by)
494 get("/statuses/:id/reblogged_by", StatusController, :reblogged_by)
495
496 get("/custom_emojis", CustomEmojiController, :index)
497
498 get("/trends", MastodonAPIController, :empty_array)
499
500 get("/timelines/public", TimelineController, :public)
501 get("/timelines/tag/:tag", TimelineController, :hashtag)
502
503 get("/polls/:id", PollController, :show)
504 end
505
506 scope "/api/v2", Pleroma.Web.MastodonAPI do
507 pipe_through(:api)
508 get("/search", SearchController, :search2)
509
510 post("/media", MediaController, :create2)
511 end
512
513 scope "/api", Pleroma.Web do
514 pipe_through(:config)
515
516 get("/pleroma/frontend_configurations", TwitterAPI.UtilController, :frontend_configurations)
517 end
518
519 scope "/api", Pleroma.Web do
520 pipe_through(:api)
521
522 get(
523 "/account/confirm_email/:user_id/:token",
524 TwitterAPI.Controller,
525 :confirm_email,
526 as: :confirm_email
527 )
528 end
529
530 scope "/api" do
531 pipe_through(:base_api)
532
533 get("/openapi", OpenApiSpex.Plug.RenderSpec, [])
534 end
535
536 scope "/api", Pleroma.Web, as: :authenticated_twitter_api do
537 pipe_through(:authenticated_api)
538
539 get("/oauth_tokens", TwitterAPI.Controller, :oauth_tokens)
540 delete("/oauth_tokens/:id", TwitterAPI.Controller, :revoke_token)
541
542 post(
543 "/qvitter/statuses/notifications/read",
544 TwitterAPI.Controller,
545 :mark_notifications_as_read
546 )
547 end
548
549 pipeline :ostatus do
550 plug(:accepts, ["html", "xml", "rss", "atom", "activity+json", "json"])
551 plug(Pleroma.Plugs.StaticFEPlug)
552 end
553
554 pipeline :oembed do
555 plug(:accepts, ["json", "xml"])
556 end
557
558 scope "/", Pleroma.Web do
559 pipe_through([:ostatus, :http_signature])
560
561 get("/objects/:uuid", OStatus.OStatusController, :object)
562 get("/activities/:uuid", OStatus.OStatusController, :activity)
563 get("/notice/:id", OStatus.OStatusController, :notice)
564 get("/notice/:id/embed_player", OStatus.OStatusController, :notice_player)
565
566 # Mastodon compatibility routes
567 get("/users/:nickname/statuses/:id", OStatus.OStatusController, :object)
568 get("/users/:nickname/statuses/:id/activity", OStatus.OStatusController, :activity)
569
570 get("/users/:nickname/feed", Feed.UserController, :feed, as: :user_feed)
571 get("/users/:nickname", Feed.UserController, :feed_redirect, as: :user_feed)
572
573 get("/tags/:tag", Feed.TagController, :feed, as: :tag_feed)
574 end
575
576 scope "/", Pleroma.Web do
577 pipe_through(:browser)
578 get("/mailer/unsubscribe/:token", Mailer.SubscriptionController, :unsubscribe)
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 get("/users/:nickname/outbox", ActivityPubController, :outbox)
606 post("/users/:nickname/outbox", ActivityPubController, :update_outbox)
607 post("/api/ap/upload_media", ActivityPubController, :upload_media)
608
609 # The following two are S2S as well, see `ActivityPub.fetch_follow_information_for_user/1`:
610 get("/users/:nickname/followers", ActivityPubController, :followers)
611 get("/users/:nickname/following", ActivityPubController, :following)
612 end
613
614 scope "/", Pleroma.Web.ActivityPub do
615 pipe_through(:activitypub)
616 post("/inbox", ActivityPubController, :inbox)
617 post("/users/:nickname/inbox", ActivityPubController, :inbox)
618 end
619
620 scope "/relay", Pleroma.Web.ActivityPub do
621 pipe_through(:ap_service_actor)
622
623 get("/", ActivityPubController, :relay)
624
625 scope [] do
626 pipe_through(:http_signature)
627 post("/inbox", ActivityPubController, :inbox)
628 end
629
630 get("/following", ActivityPubController, :relay_following)
631 get("/followers", ActivityPubController, :relay_followers)
632 end
633
634 scope "/internal/fetch", Pleroma.Web.ActivityPub do
635 pipe_through(:ap_service_actor)
636
637 get("/", ActivityPubController, :internal_fetch)
638 post("/inbox", ActivityPubController, :inbox)
639 end
640
641 scope "/.well-known", Pleroma.Web do
642 pipe_through(:well_known)
643
644 get("/host-meta", WebFinger.WebFingerController, :host_meta)
645 get("/webfinger", WebFinger.WebFingerController, :webfinger)
646 get("/nodeinfo", Nodeinfo.NodeinfoController, :schemas)
647 end
648
649 scope "/nodeinfo", Pleroma.Web do
650 get("/:version", Nodeinfo.NodeinfoController, :nodeinfo)
651 end
652
653 scope "/", Pleroma.Web do
654 pipe_through(:api)
655
656 get("/web/manifest.json", MastoFEController, :manifest)
657 end
658
659 scope "/", Pleroma.Web do
660 pipe_through(:mastodon_html)
661
662 get("/web/login", MastodonAPI.AuthController, :login)
663 delete("/auth/sign_out", MastodonAPI.AuthController, :logout)
664
665 post("/auth/password", MastodonAPI.AuthController, :password_reset)
666
667 get("/web/*path", MastoFEController, :index)
668
669 get("/embed/:id", EmbedController, :show)
670 end
671
672 scope "/proxy/", Pleroma.Web.MediaProxy do
673 get("/preview/:sig/:url", MediaProxyController, :preview)
674 get("/preview/:sig/:url/:filename", MediaProxyController, :preview)
675 get("/:sig/:url", MediaProxyController, :remote)
676 get("/:sig/:url/:filename", MediaProxyController, :remote)
677 end
678
679 if Pleroma.Config.get(:env) == :dev do
680 scope "/dev" do
681 pipe_through([:mailbox_preview])
682
683 forward("/mailbox", Plug.Swoosh.MailboxPreview, base_path: "/dev/mailbox")
684 end
685 end
686
687 # Test-only routes needed to test action dispatching and plug chain execution
688 if Pleroma.Config.get(:env) == :test do
689 @test_actions [
690 :do_oauth_check,
691 :fallback_oauth_check,
692 :skip_oauth_check,
693 :fallback_oauth_skip_publicity_check,
694 :skip_oauth_skip_publicity_check,
695 :missing_oauth_check_definition
696 ]
697
698 scope "/test/api", Pleroma.Tests do
699 pipe_through(:api)
700
701 for action <- @test_actions do
702 get("/#{action}", AuthTestController, action)
703 end
704 end
705
706 scope "/test/authenticated_api", Pleroma.Tests do
707 pipe_through(:authenticated_api)
708
709 for action <- @test_actions do
710 get("/#{action}", AuthTestController, action)
711 end
712 end
713 end
714
715 scope "/", Pleroma.Web.MongooseIM do
716 get("/user_exists", MongooseIMController, :user_exists)
717 get("/check_password", MongooseIMController, :check_password)
718 end
719
720 scope "/", Fallback do
721 get("/registration/:token", RedirectController, :registration_page)
722 get("/:maybe_nickname_or_id", RedirectController, :redirector_with_meta)
723 get("/api*path", RedirectController, :api_not_implemented)
724 get("/*path", RedirectController, :redirector_with_preload)
725
726 options("/*path", RedirectController, :empty)
727 end
728 end