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