mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-18 08:43:57 +00:00
feat: correctly get own friends
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { userAuthRepository } from "@main/repository";
|
||||
import { registerEvent } from "../register-event";
|
||||
import { HydraApi } from "@main/services";
|
||||
import { UserFriends } from "@types";
|
||||
@@ -7,9 +8,19 @@ export const getUserFriends = async (
|
||||
take: number,
|
||||
skip: number
|
||||
): Promise<UserFriends> => {
|
||||
const loggedUser = await userAuthRepository.findOne({ where: { id: 1 } });
|
||||
|
||||
if (loggedUser?.userId == userId) {
|
||||
return HydraApi.get(`/profile/friends`, { take, skip }).catch(
|
||||
(_err) => {
|
||||
return { totalFriends: 0, friends: [] };
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return HydraApi.get(`/user/${userId}/friends`, { take, skip }).catch(
|
||||
(_err) => {
|
||||
return { totalFriends: 0, friends: [] } as UserFriends;
|
||||
return { totalFriends: 0, friends: [] };
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user