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