From bde396c7dbfc16ab29323bbeb8abc91c995f99ad Mon Sep 17 00:00:00 2001 From: Zamitto <167933696+zamitto@users.noreply.github.com> Date: Mon, 19 Aug 2024 19:55:27 -0300 Subject: [PATCH] feat: update endpoints --- src/main/events/library/remove-game-from-library.ts | 2 +- src/main/events/user/block-user.ts | 2 +- src/main/events/user/get-user-friends.ts | 2 +- src/main/events/user/get-user.ts | 2 +- src/main/events/user/unblock-user.ts | 2 +- src/main/services/library-sync/create-game.ts | 2 +- src/main/services/library-sync/merge-with-remote-games.ts | 2 +- src/main/services/library-sync/update-game-playtime.ts | 2 +- src/main/services/library-sync/upload-games-batch.ts | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/events/library/remove-game-from-library.ts b/src/main/events/library/remove-game-from-library.ts index 468f5b26..a8fc8b01 100644 --- a/src/main/events/library/remove-game-from-library.ts +++ b/src/main/events/library/remove-game-from-library.ts @@ -20,7 +20,7 @@ const removeRemoveGameFromLibrary = async (gameId: number) => { const game = await gameRepository.findOne({ where: { id: gameId } }); if (game?.remoteId) { - HydraApi.delete(`/games/${game.remoteId}`).catch(() => {}); + HydraApi.delete(`/profile/games/${game.remoteId}`).catch(() => {}); } }; diff --git a/src/main/events/user/block-user.ts b/src/main/events/user/block-user.ts index 8003f478..c81231e5 100644 --- a/src/main/events/user/block-user.ts +++ b/src/main/events/user/block-user.ts @@ -5,7 +5,7 @@ const blockUser = async ( _event: Electron.IpcMainInvokeEvent, userId: string ) => { - await HydraApi.post(`/user/${userId}/block`); + await HydraApi.post(`/users/${userId}/block`); }; registerEvent("blockUser", blockUser); diff --git a/src/main/events/user/get-user-friends.ts b/src/main/events/user/get-user-friends.ts index 28783459..5ff4c8a4 100644 --- a/src/main/events/user/get-user-friends.ts +++ b/src/main/events/user/get-user-friends.ts @@ -14,7 +14,7 @@ export const getUserFriends = async ( return HydraApi.get(`/profile/friends`, { take, skip }); } - return HydraApi.get(`/user/${userId}/friends`, { take, skip }); + return HydraApi.get(`/users/${userId}/friends`, { take, skip }); }; const getUserFriendsEvent = async ( diff --git a/src/main/events/user/get-user.ts b/src/main/events/user/get-user.ts index bc4a58ad..d3be856a 100644 --- a/src/main/events/user/get-user.ts +++ b/src/main/events/user/get-user.ts @@ -12,7 +12,7 @@ const getUser = async ( ): Promise => { try { const [profile, friends] = await Promise.all([ - HydraApi.get(`/user/${userId}`), + HydraApi.get(`/users/${userId}`), getUserFriends(userId, 12, 0).catch(() => { return { totalFriends: 0, friends: [] }; }), diff --git a/src/main/events/user/unblock-user.ts b/src/main/events/user/unblock-user.ts index ac678dbd..c604a0b5 100644 --- a/src/main/events/user/unblock-user.ts +++ b/src/main/events/user/unblock-user.ts @@ -5,7 +5,7 @@ const unblockUser = async ( _event: Electron.IpcMainInvokeEvent, userId: string ) => { - await HydraApi.post(`/user/${userId}/unblock`); + await HydraApi.post(`/users/${userId}/unblock`); }; registerEvent("unblockUser", unblockUser); diff --git a/src/main/services/library-sync/create-game.ts b/src/main/services/library-sync/create-game.ts index b66a1897..6699788c 100644 --- a/src/main/services/library-sync/create-game.ts +++ b/src/main/services/library-sync/create-game.ts @@ -3,7 +3,7 @@ import { HydraApi } from "../hydra-api"; import { gameRepository } from "@main/repository"; export const createGame = async (game: Game) => { - HydraApi.post(`/games`, { + HydraApi.post(`/profile/games`, { objectId: game.objectID, playTimeInMilliseconds: Math.trunc(game.playTimeInMilliseconds), shop: game.shop, diff --git a/src/main/services/library-sync/merge-with-remote-games.ts b/src/main/services/library-sync/merge-with-remote-games.ts index 2a6b5bb5..2b3f51b3 100644 --- a/src/main/services/library-sync/merge-with-remote-games.ts +++ b/src/main/services/library-sync/merge-with-remote-games.ts @@ -4,7 +4,7 @@ import { steamGamesWorker } from "@main/workers"; import { getSteamAppAsset } from "@main/helpers"; export const mergeWithRemoteGames = async () => { - return HydraApi.get("/games") + return HydraApi.get("/profile/games") .then(async (response) => { for (const game of response) { const localGame = await gameRepository.findOne({ diff --git a/src/main/services/library-sync/update-game-playtime.ts b/src/main/services/library-sync/update-game-playtime.ts index 39206a12..5cfc4103 100644 --- a/src/main/services/library-sync/update-game-playtime.ts +++ b/src/main/services/library-sync/update-game-playtime.ts @@ -6,7 +6,7 @@ export const updateGamePlaytime = async ( deltaInMillis: number, lastTimePlayed: Date ) => { - HydraApi.put(`/games/${game.remoteId}`, { + HydraApi.put(`/profile/games/${game.remoteId}`, { playTimeDeltaInSeconds: Math.trunc(deltaInMillis / 1000), lastTimePlayed, }).catch(() => {}); diff --git a/src/main/services/library-sync/upload-games-batch.ts b/src/main/services/library-sync/upload-games-batch.ts index 88f02375..22dc595e 100644 --- a/src/main/services/library-sync/upload-games-batch.ts +++ b/src/main/services/library-sync/upload-games-batch.ts @@ -14,7 +14,7 @@ export const uploadGamesBatch = async () => { for (const chunk of gamesChunks) { await HydraApi.post( - "/games/batch", + "/profile/games/batch", chunk.map((game) => { return { objectId: game.objectID,