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