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