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