profile service
This commit is contained in:
parent
56aa416751
commit
a2939a7f2e
2 changed files with 38 additions and 31 deletions
|
|
@ -6,7 +6,8 @@ class ServicesProvider {
|
||||||
const nostrService = require('../services/nostrService');
|
const nostrService = require('../services/nostrService');
|
||||||
const loginService = require('../services/loginService');
|
const loginService = require('../services/loginService');
|
||||||
const sessionService = require('../services/sessionService');
|
const sessionService = require('../services/sessionService');
|
||||||
const profileService = require('../services/profileService');
|
const ProfileServiceProvider = require('../services/profileService');
|
||||||
|
const profileService = new ProfileServiceProvider().provide();
|
||||||
const OfferServiceProvider = require('../services/offerService');
|
const OfferServiceProvider = require('../services/offerService');
|
||||||
const offerService = new OfferServiceProvider().provide();
|
const offerService = new OfferServiceProvider().provide();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,35 +2,41 @@ const uuid = require('uuid');
|
||||||
|
|
||||||
const models = require('../models');
|
const models = require('../models');
|
||||||
|
|
||||||
async function setContactDetails(publicKey, encryptedContactDetails) {
|
class ProfileServiceProvider {
|
||||||
return await models.ContactDetailsSet.create({
|
provide() {
|
||||||
uuid: uuid.v7(),
|
async function setContactDetails(publicKey, encryptedContactDetails) {
|
||||||
public_key: publicKey,
|
return await models.ContactDetailsSet.create({
|
||||||
encrypted_contact_details: encryptedContactDetails,
|
uuid: uuid.v7(),
|
||||||
created_at: new Date().toISOString(),
|
public_key: publicKey,
|
||||||
});
|
encrypted_contact_details: encryptedContactDetails,
|
||||||
|
created_at: new Date().toISOString(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function setNym(publicKey, nym) {
|
||||||
|
return await models.NymSet.create({
|
||||||
|
uuid: uuid.v7(),
|
||||||
|
public_key: publicKey,
|
||||||
|
nym: nym,
|
||||||
|
created_at: new Date().toISOString(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function areProfileDetailsComplete(publicKey) {
|
||||||
|
const isNymSet = await models.NymSet.findOne({
|
||||||
|
where: { public_key: publicKey },
|
||||||
|
});
|
||||||
|
const areContactDetailsSet = await models.ContactDetailsSet.findOne({
|
||||||
|
where: {
|
||||||
|
public_key: publicKey,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return isNymSet && areContactDetailsSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
return { setContactDetails, setNym, areProfileDetailsComplete };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setNym(publicKey, nym) {
|
module.exports = ProfileServiceProvider;
|
||||||
return await models.NymSet.create({
|
|
||||||
uuid: uuid.v7(),
|
|
||||||
public_key: publicKey,
|
|
||||||
nym: nym,
|
|
||||||
created_at: new Date().toISOString(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async function areProfileDetailsComplete(publicKey) {
|
|
||||||
const isNymSet = await models.NymSet.findOne({
|
|
||||||
where: { public_key: publicKey },
|
|
||||||
});
|
|
||||||
const areContactDetailsSet = await models.ContactDetailsSet.findOne({
|
|
||||||
where: {
|
|
||||||
public_key: publicKey,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return isNymSet && areContactDetailsSet;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = { setContactDetails, setNym, areProfileDetailsComplete };
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue