diff options
Diffstat (limited to 'src/controller/friend.ts')
-rw-r--r-- | src/controller/friend.ts | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/controller/friend.ts b/src/controller/friend.ts index a73d3d1..f528858 100644 --- a/src/controller/friend.ts +++ b/src/controller/friend.ts @@ -19,6 +19,7 @@ import { Request, Response } from "express"; import { getFriendToken } from "../util/auth"; import { friend, unfriend, list } from "../service/friend"; import jwt from "jsonwebtoken"; +import {readById} from "../service/user"; const friendRequest = async (req: Request, res: Response) => { try { @@ -55,12 +56,21 @@ const addFriend = async (req: Request, res: Response) => { } else { try { // @ts-ignore - const _ = await friend(claims.userId, req.userId); - res.status(200).json({ message: "success" }); + const f = await friend(claims.userId, req.userId); + // @ts-ignore + delete f["password"]; + // @ts-ignore + delete f["refreshTokenVersion"]; + // @ts-ignore + delete f["createdAt"]; + // @ts-ignore + delete f["updatedAt"]; + + res.status(200).json({ friend: f }); } catch (error) { // @ts-ignore if (error.code == "P2002") { - res.status(409).json({ error: "Already friends" }); + res.status(409).json({error: "Already friends"}); } else { res.status(500).json({ error: "Internal Server Error" }); console.error(error); |