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 loginService = require('../services/loginService');
|
||||
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 offerService = new OfferServiceProvider().provide();
|
||||
|
||||
|
|
|
|||
|
|
@ -2,35 +2,41 @@ const uuid = require('uuid');
|
|||
|
||||
const models = require('../models');
|
||||
|
||||
async function setContactDetails(publicKey, encryptedContactDetails) {
|
||||
return await models.ContactDetailsSet.create({
|
||||
uuid: uuid.v7(),
|
||||
public_key: publicKey,
|
||||
encrypted_contact_details: encryptedContactDetails,
|
||||
created_at: new Date().toISOString(),
|
||||
});
|
||||
class ProfileServiceProvider {
|
||||
provide() {
|
||||
async function setContactDetails(publicKey, encryptedContactDetails) {
|
||||
return await models.ContactDetailsSet.create({
|
||||
uuid: uuid.v7(),
|
||||
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) {
|
||||
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 };
|
||||
module.exports = ProfileServiceProvider;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue