mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
feat: add getUserFriends event
This commit is contained in:
parent
380143c780
commit
010f07373d
4 changed files with 15 additions and 9 deletions
|
|
@ -43,6 +43,7 @@ import "./auth/sign-out";
|
|||
import "./auth/open-auth-window";
|
||||
import "./auth/get-session-hash";
|
||||
import "./user/get-user";
|
||||
import "./user/get-user-friends";
|
||||
import "./profile/get-friend-requests";
|
||||
import "./profile/get-me";
|
||||
import "./profile/update-friend-request";
|
||||
|
|
|
|||
|
|
@ -8,21 +8,23 @@ export const getUserFriends = async (
|
|||
take: number,
|
||||
skip: number
|
||||
): Promise<UserFriends> => {
|
||||
const loggedUser = await userAuthRepository.findOne({ where: { id: 1 } });
|
||||
try {
|
||||
const loggedUser = await userAuthRepository.findOne({ where: { id: 1 } });
|
||||
|
||||
if (loggedUser?.userId == userId) {
|
||||
return HydraApi.get(`/profile/friends`, { take, skip }).catch(
|
||||
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: [] };
|
||||
}
|
||||
);
|
||||
} catch (err) {
|
||||
return { totalFriends: 0, friends: [] };
|
||||
}
|
||||
|
||||
return HydraApi.get(`/user/${userId}/friends`, { take, skip }).catch(
|
||||
(_err) => {
|
||||
return { totalFriends: 0, friends: [] };
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const getUserFriendsEvent = async (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue