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