check if invite is spent

This commit is contained in:
counterweight 2025-02-10 00:17:30 +01:00
parent c8ddd96743
commit e48def3661
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
3 changed files with 20 additions and 17 deletions

View file

@ -1,4 +1,5 @@
const AppInvite = require('../models/AppInvite');
const InvitedNpub = require('../models/InvitedNpub');
async function appInviteExists(inviteUuid) {
const invite = await AppInvite.findOne({ where: { uuid: inviteUuid } });
@ -8,11 +9,25 @@ async function appInviteExists(inviteUuid) {
return false;
}
async function getInvite(inviteUuid) {
async function getAppInvite(inviteUuid) {
const invite = await AppInvite.findOne({ where: { uuid: inviteUuid } });
return invite;
}
async function isAppInviteSpent(inviteUuid) {
const invitedNpub = await InvitedNpub.findOne({
where: {
app_invite_uuid: inviteUuid
}
})
if (invitedNpub) {
return true;
}
return false;
}
exports.appInviteExists = appInviteExists;
exports.getInvite = getInvite;
exports.getAppInvite = getAppInvite;
exports.isAppInviteSpent = isAppInviteSpent;