all serviced

This commit is contained in:
counterweight 2025-02-10 01:42:46 +01:00
parent 79f02f70cc
commit b4bd150d93
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
2 changed files with 9 additions and 9 deletions

View file

@ -1,7 +1,4 @@
const express = require('express'); const express = require('express');
const uuid = require("uuid");
const SessionNpubbed = require('../models/SessionNpubbed');
const appInviteService = require('../services/appInviteService'); const appInviteService = require('../services/appInviteService');
const invitedNpubService = require('../services/invitedNpubService'); const invitedNpubService = require('../services/invitedNpubService');
@ -18,12 +15,7 @@ router.post('/session-npubbed', async (req, res) => {
} }
try { try {
const existingRecord = await SessionNpubbed.findOne({ if (await sessionService.isSessionAlreadyRelatedToNpub(sessionUuid, npub)) {
where: { 'session_uuid': sessionUuid, npub }
});
if (existingRecord) {
console.log("Record already exists. No need to create a new one.");
return res.json({ message: 'SessionNpubbed record already exists' }); return res.json({ message: 'SessionNpubbed record already exists' });
} }
console.log("No matching record found. Creating a new one..."); console.log("No matching record found. Creating a new one...");

View file

@ -19,5 +19,13 @@ async function relateSessionToNpub(sessionUuid, npub) {
}); });
} }
async function isSessionAlreadyRelatedToNpub(sessionUuid, npub) {
if (await SessionNpubbed.findOne({ where: { 'session_uuid': sessionUuid, npub } })) {
return true;
}
return false;
}
exports.createSession = createSession; exports.createSession = createSession;
exports.relateSessionToNpub = relateSessionToNpub; exports.relateSessionToNpub = relateSessionToNpub;
exports.isSessionAlreadyRelatedToNpub = isSessionAlreadyRelatedToNpub;