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