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