1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2025-06-20 00:25:17 +00:00

Return the like status of a user over a group

This commit is contained in:
2019-12-25 15:31:41 +01:00
parent 91f0413963
commit 7b36e092b1
2 changed files with 21 additions and 0 deletions

View File

@ -49,4 +49,24 @@ export class LikesHelper {
})
}
/**
* Check out whether the user likes an element or not
*
* @param userID ID of the user
* @param id ID of the thing to check
* @param type The kind of the element
*/
public static async IsLiking(userID: number, id: number, type: LikesType) : Promise<boolean> {
if(userID == 0) return false;
return await DatabaseHelper.Count({
table: LIKES_TABLE,
where: {
ID_type: id,
type: LikesKindsDB[type],
ID_personne: userID
}
}) == 1;
}
}