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