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