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