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