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