Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into remake-remodel-dms
[akkoma] / lib / pleroma / web / router.ex
index a7e1f2f57a43032c589b88a6adaf8b9b99cb414a..89db2eebd5beb73ccac34c83998374afa1864182 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,6 +189,7 @@ 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)
@@ -214,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
 
@@ -257,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)
@@ -268,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)
 
@@ -286,6 +303,18 @@ defmodule Pleroma.Web.Router do
   end
 
   scope "/api/v1/pleroma", Pleroma.Web.PleromaAPI do
+    scope [] do
+      pipe_through(:authenticated_api)
+
+      post("/chats/by-account-id/:id", ChatController, :create)
+      get("/chats", ChatController, :index)
+      get("/chats/:id", ChatController, :show)
+      get("/chats/:id/messages", ChatController, :messages)
+      post("/chats/:id/messages", ChatController, :post_chat_message)
+      delete("/chats/:id/messages/:message_id", ChatController, :delete_message)
+      post("/chats/:id/read", ChatController, :mark_as_read)
+    end
+
     scope [] do
       pipe_through(:authenticated_api)
 
@@ -309,7 +338,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
@@ -329,7 +358,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
@@ -387,6 +416,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)
@@ -396,7 +426,7 @@ defmodule Pleroma.Web.Router do
     post("/notifications/clear", NotificationController, :clear)
     delete("/notifications/destroy_multiple", NotificationController, :destroy_multiple)
     # Deprecated: was removed in Mastodon v3, use `/notifications/:id/dismiss` instead
-    post("/notifications/dismiss", NotificationController, :dismiss)
+    post("/notifications/dismiss", NotificationController, :dismiss_via_body)
 
     post("/polls/:id/votes", PollController, :vote)
 
@@ -426,7 +456,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)
 
@@ -481,6 +511,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
@@ -585,6 +617,7 @@ defmodule Pleroma.Web.Router do
     post("/users/:nickname/outbox", ActivityPubController, :update_outbox)
     post("/api/ap/upload_media", ActivityPubController, :upload_media)
 
+    # The following two are S2S as well, see `ActivityPub.fetch_follow_information_for_user/1`:
     get("/users/:nickname/followers", ActivityPubController, :followers)
     get("/users/:nickname/following", ActivityPubController, :following)
   end