relate session to npub
This commit is contained in:
parent
36dba606de
commit
79f02f70cc
2 changed files with 20 additions and 11 deletions
|
|
@ -3,8 +3,9 @@ const uuid = require("uuid");
|
||||||
|
|
||||||
const SessionNpubbed = require('../models/SessionNpubbed');
|
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');
|
||||||
|
const sessionService = require('../services/sessionService');
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
|
|
@ -25,16 +26,12 @@ router.post('/session-npubbed', async (req, res) => {
|
||||||
console.log("Record already exists. No need to create a new one.");
|
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...");
|
||||||
|
|
||||||
await SessionNpubbed.create({
|
await sessionService.relateSessionToNpub(
|
||||||
session_npubbed_uuid: uuid.v7(),
|
sessionUuid,
|
||||||
session_uuid: sessionUuid,
|
npub
|
||||||
npub,
|
);
|
||||||
created_at: new Date().toISOString()
|
|
||||||
});
|
|
||||||
|
|
||||||
return res.json({ message: 'SessionNpubbed record created successfully' });
|
return res.json({ message: 'SessionNpubbed record created successfully' });
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
|
const uuid = require("uuid");
|
||||||
|
|
||||||
const Session = require('../models/Session');
|
const Session = require('../models/Session');
|
||||||
|
const SessionNpubbed = require('../models/SessionNpubbed');
|
||||||
|
|
||||||
async function createSession(sessionUuid) {
|
async function createSession(sessionUuid) {
|
||||||
await Session.create({
|
await Session.create({
|
||||||
|
|
@ -7,5 +10,14 @@ async function createSession(sessionUuid) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.createSession = createSession;
|
async function relateSessionToNpub(sessionUuid, npub) {
|
||||||
|
await SessionNpubbed.create({
|
||||||
|
session_npubbed_uuid: uuid.v7(),
|
||||||
|
session_uuid: sessionUuid,
|
||||||
|
npub,
|
||||||
|
created_at: new Date().toISOString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.createSession = createSession;
|
||||||
|
exports.relateSessionToNpub = relateSessionToNpub;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue