Skip to content

Commit

Permalink
feat: add new isMembershipActive function
Browse files Browse the repository at this point in the history
  • Loading branch information
Ratchet7x5 committed Dec 9, 2024
1 parent 4a49583 commit 247bbb4
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions api/gateway/userGateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,30 @@ export async function getUserMembershipExpiryDate(
return returnDate;
}

export async function isMembershipActive(userEmail: string): Promise<boolean> {
let isActive = false;

if (userEmail === "" || userEmail === undefined || userEmail === null) {
throw new Error(
"isMembershipActive: received invalid type for userEmail: " + userEmail
);
}

let isMember = await db
.select({ isMember: peoples.isMember })
.from(peoples)
.where(eq(peoples.email, userEmail))
.limit(1);

if (isMember.length === 1) {
if (isMember[0].isMember !== undefined || isMember[0].isMember !== null) {
isActive = isMember[0].isMember!;
}
}

return isActive;
}

export async function insertUserTicket(data: {
ticketId: number;
name: string;
Expand Down

0 comments on commit 247bbb4

Please sign in to comment.