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 appInviteService = require('../services/appInviteService')
|
||||
const invitedNpubService = require('../services/invitedNpubService')
|
||||
const appInviteService = require('../services/appInviteService');
|
||||
const invitedNpubService = require('../services/invitedNpubService');
|
||||
const sessionService = require('../services/sessionService');
|
||||
|
||||
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.");
|
||||
return res.json({ message: 'SessionNpubbed record already exists' });
|
||||
}
|
||||
|
||||
|
||||
console.log("No matching record found. Creating a new one...");
|
||||
|
||||
await SessionNpubbed.create({
|
||||
session_npubbed_uuid: uuid.v7(),
|
||||
session_uuid: sessionUuid,
|
||||
npub,
|
||||
created_at: new Date().toISOString()
|
||||
});
|
||||
await sessionService.relateSessionToNpub(
|
||||
sessionUuid,
|
||||
npub
|
||||
);
|
||||
|
||||
return res.json({ message: 'SessionNpubbed record created successfully' });
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
const uuid = require("uuid");
|
||||
|
||||
const Session = require('../models/Session');
|
||||
const SessionNpubbed = require('../models/SessionNpubbed');
|
||||
|
||||
async function createSession(sessionUuid) {
|
||||
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