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