all serviced
This commit is contained in:
parent
79f02f70cc
commit
b4bd150d93
2 changed files with 9 additions and 9 deletions
|
|
@ -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...");
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue