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