Skip to content

Commit 8f7bf17

Browse files
authored
Merge pull request #28 from Capstone-C1SE04-TI/FIX-MAIN
fix unfollow
2 parents fab6b75 + a8da40e commit 8f7bf17

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/controllers/User.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -219,18 +219,17 @@ function UserController() {
219219
this.unfollowSharkWallet = async (req, res, next) => {
220220
let { userId, sharkId } = req.body;
221221

222-
if (!userId) userId = null;
222+
if (!userId || _.isEmpty(userId)) userId = null;
223223
else {
224224
if (isNaN(userId)) userId = undefined;
225225
else userId = Number(userId);
226226
}
227227

228-
if (!sharkId) sharkId = null;
228+
if (!sharkId || _.isEmpty(sharkId)) sharkId = null;
229229
else {
230230
if (isNaN(sharkId)) sharkId = undefined;
231231
else sharkId = Number(sharkId);
232232
}
233-
234233
await unfollowWalletOfShark(userId, sharkId)
235234
.then((data) => {
236235
if (data.message === "success")

src/services/crud-database/user.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ const followWalletOfShark = async (userId, sharkId) => {
239239

240240
const unfollowWalletOfShark = async (userId, sharkId) => {
241241
try {
242-
if (userId === null) return "userid-required";
243-
if (userId === undefined) return "userid-invalid";
242+
if (userId === null) return { message: "userid-required"};
243+
if (userId === undefined) return { message: "userid-invalid"};
244244
if (sharkId === null) return { message: "sharkid-required" };
245245
if (sharkId === undefined) return { message: "sharkid-invalid" };
246246

@@ -271,7 +271,6 @@ const unfollowWalletOfShark = async (userId, sharkId) => {
271271

272272
return {
273273
message: "success",
274-
data: { ...shark, unfollowed: true }
275274
};
276275
} catch (error) {
277276
return { message: "error-unfollow-failed", error: error };
@@ -348,7 +347,7 @@ const getTransactionsOfAllSharks = async (page, valueFilter = 0) => {
348347
.sort({ timeStamp: "desc" })
349348
.skip((page - 1) * QUERY_LIMIT_ITEM)
350349
.limit(QUERY_LIMIT_ITEM);
351-
350+
352351
return transactions || [];
353352
};
354353

0 commit comments

Comments
 (0)