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