Merge branch 'chore/bump-hackney' into 'develop'
[akkoma] / lib / pleroma / web / router.ex
index ef2239d591c279f0fb19dd07c85d3b326e067a33..e493a41534bb0f8b3a0a11e0eb6ec7714e4fd803 100644 (file)
@@ -132,6 +132,7 @@ defmodule Pleroma.Web.Router do
     post("/users/follow", AdminAPIController, :user_follow)
     post("/users/unfollow", AdminAPIController, :user_unfollow)
 
+    put("/users/disable_mfa", AdminAPIController, :disable_mfa)
     delete("/users", AdminAPIController, :user_delete)
     post("/users", AdminAPIController, :users_create)
     patch("/users/:nickname/toggle_activation", AdminAPIController, :user_toggle_activation)
@@ -188,10 +189,10 @@ defmodule Pleroma.Web.Router do
     post("/reports/:id/notes", AdminAPIController, :report_notes_create)
     delete("/reports/:report_id/notes/:id", AdminAPIController, :report_notes_delete)
 
-    get("/statuses/:id", AdminAPIController, :status_show)
-    put("/statuses/:id", AdminAPIController, :status_update)
-    delete("/statuses/:id", AdminAPIController, :status_delete)
-    get("/statuses", AdminAPIController, :list_statuses)
+    get("/statuses/:id", StatusController, :show)
+    put("/statuses/:id", StatusController, :update)
+    delete("/statuses/:id", StatusController, :delete)
+    get("/statuses", StatusController, :index)
 
     get("/config", AdminAPIController, :config_show)
     post("/config", AdminAPIController, :config_update)
@@ -215,24 +216,25 @@ defmodule Pleroma.Web.Router do
     scope "/packs" do
       pipe_through(:admin_api)
 
-      get("/import", EmojiAPIController, :import_from_filesystem)
-      get("/remote", EmojiAPIController, :remote)
-      post("/download", EmojiAPIController, :download)
+      get("/import", EmojiPackController, :import_from_filesystem)
+      get("/remote", EmojiPackController, :remote)
+      post("/download", EmojiPackController, :download)
 
-      post("/:name", EmojiAPIController, :create)
-      patch("/:name", EmojiAPIController, :update)
-      delete("/:name", EmojiAPIController, :delete)
+      post("/:name", EmojiPackController, :create)
+      patch("/:name", EmojiPackController, :update)
+      delete("/:name", EmojiPackController, :delete)
 
-      post("/:name/files", EmojiAPIController, :add_file)
-      patch("/:name/files", EmojiAPIController, :update_file)
-      delete("/:name/files", EmojiAPIController, :delete_file)
+      post("/:name/files", EmojiPackController, :add_file)
+      patch("/:name/files", EmojiPackController, :update_file)
+      delete("/:name/files", EmojiPackController, :delete_file)
     end
 
     # Pack info / downloading
     scope "/packs" do
-      get("/", EmojiAPIController, :list)
-      get("/:name", EmojiAPIController, :show)
-      get("/:name/archive", EmojiAPIController, :archive)
+      pipe_through(:api)
+      get("/", EmojiPackController, :index)
+      get("/:name", EmojiPackController, :show)
+      get("/:name/archive", EmojiPackController, :archive)
     end
   end
 
@@ -258,6 +260,16 @@ defmodule Pleroma.Web.Router do
     post("/follow_import", UtilController, :follow_import)
   end
 
+  scope "/api/pleroma", Pleroma.Web.PleromaAPI do
+    pipe_through(:authenticated_api)
+
+    get("/accounts/mfa", TwoFactorAuthenticationController, :settings)
+    get("/accounts/mfa/backup_codes", TwoFactorAuthenticationController, :backup_codes)
+    get("/accounts/mfa/setup/:method", TwoFactorAuthenticationController, :setup)
+    post("/accounts/mfa/confirm/:method", TwoFactorAuthenticationController, :confirm)
+    delete("/accounts/mfa/:method", TwoFactorAuthenticationController, :disable)
+  end
+
   scope "/oauth", Pleroma.Web.OAuth do
     scope [] do
       pipe_through(:oauth)
@@ -269,6 +281,10 @@ defmodule Pleroma.Web.Router do
     post("/revoke", OAuthController, :token_revoke)
     get("/registration_details", OAuthController, :registration_details)
 
+    post("/mfa/challenge", MFAController, :challenge)
+    post("/mfa/verify", MFAController, :verify, as: :mfa_verify)
+    get("/mfa", MFAController, :show)
+
     scope [] do
       pipe_through(:browser)
 
@@ -282,26 +298,22 @@ defmodule Pleroma.Web.Router do
   scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do
     pipe_through(:api)
 
-    get("/statuses/:id/reactions/:emoji", PleromaAPIController, :emoji_reactions_by)
-    get("/statuses/:id/reactions", PleromaAPIController, :emoji_reactions_by)
+    get("/statuses/:id/reactions/:emoji", EmojiReactionController, :index)
+    get("/statuses/:id/reactions", EmojiReactionController, :index)
   end
 
   scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do
     scope [] do
       pipe_through(:authenticated_api)
 
-      get("/conversations/:id/statuses", PleromaAPIController, :conversation_statuses)
-      get("/conversations/:id", PleromaAPIController, :conversation)
-      post("/conversations/read", PleromaAPIController, :mark_conversations_as_read)
-    end
+      get("/conversations/:id/statuses", ConversationController, :statuses)
+      get("/conversations/:id", ConversationController, :show)
+      post("/conversations/read", ConversationController, :mark_as_read)
+      patch("/conversations/:id", ConversationController, :update)
 
-    scope [] do
-      pipe_through(:authenticated_api)
-
-      patch("/conversations/:id", PleromaAPIController, :update_conversation)
-      put("/statuses/:id/reactions/:emoji", PleromaAPIController, :react_with_emoji)
-      delete("/statuses/:id/reactions/:emoji", PleromaAPIController, :unreact_with_emoji)
-      post("/notifications/read", PleromaAPIController, :mark_notifications_as_read)
+      put("/statuses/:id/reactions/:emoji", EmojiReactionController, :create)
+      delete("/statuses/:id/reactions/:emoji", EmojiReactionController, :delete)
+      post("/notifications/read", NotificationController, :mark_as_read)
 
       patch("/accounts/update_avatar", AccountController, :update_avatar)
       patch("/accounts/update_banner", AccountController, :update_banner)
@@ -310,7 +322,7 @@ defmodule Pleroma.Web.Router do
       get("/mascot", MascotController, :show)
       put("/mascot", MascotController, :update)
 
-      post("/scrobble", ScrobbleController, :new_scrobble)
+      post("/scrobble", ScrobbleController, :create)
     end
 
     scope [] do
@@ -330,7 +342,7 @@ defmodule Pleroma.Web.Router do
 
   scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do
     pipe_through(:api)
-    get("/accounts/:id/scrobbles", ScrobbleController, :user_scrobbles)
+    get("/accounts/:id/scrobbles", ScrobbleController, :index)
   end
 
   scope "/api/v1", Pleroma.Web.MastodonAPI do
@@ -388,6 +400,7 @@ defmodule Pleroma.Web.Router do
     post("/markers", MarkerController, :upsert)
 
     post("/media", MediaController, :create)
+    get("/media/:id", MediaController, :show)
     put("/media/:id", MediaController, :update)
 
     get("/notifications", NotificationController, :index)
@@ -427,7 +440,7 @@ defmodule Pleroma.Web.Router do
     post("/statuses/:id/unmute", StatusController, :unmute_conversation)
 
     post("/push/subscription", SubscriptionController, :create)
-    get("/push/subscription", SubscriptionController, :get)
+    get("/push/subscription", SubscriptionController, :show)
     put("/push/subscription", SubscriptionController, :update)
     delete("/push/subscription", SubscriptionController, :delete)
 
@@ -482,6 +495,8 @@ defmodule Pleroma.Web.Router do
   scope "/api/v2", Pleroma.Web.MastodonAPI do
     pipe_through(:api)
     get("/search", SearchController, :search2)
+
+    post("/media", MediaController, :create2)
   end
 
   scope "/api", Pleroma.Web do
@@ -541,6 +556,10 @@ defmodule Pleroma.Web.Router do
     get("/notice/:id", OStatus.OStatusController, :notice)
     get("/notice/:id/embed_player", OStatus.OStatusController, :notice_player)
 
+    # Mastodon compatibility routes
+    get("/users/:nickname/statuses/:id", OStatus.OStatusController, :object)
+    get("/users/:nickname/statuses/:id/activity", OStatus.OStatusController, :activity)
+
     get("/users/:nickname/feed", Feed.UserController, :feed, as: :user_feed)
     get("/users/:nickname", Feed.UserController, :feed_redirect, as: :user_feed)