|
|
|
@ -340,28 +340,21 @@ exports.uploadProfilePicture = async (req, reply) => {
|
|
|
|
|
try {
|
|
|
|
|
const customerId = req.params.customerId;
|
|
|
|
|
const picture = new Buffer.from(req.body.picture, 'base64');
|
|
|
|
|
|
|
|
|
|
let profilePicture = await ProfilePicture.findOne({ customerId });
|
|
|
|
|
|
|
|
|
|
const profilePicture = new ProfilePicture({ customerId, picture });
|
|
|
|
|
await profilePicture.save();
|
|
|
|
|
|
|
|
|
|
return { message: 'Profile picture uploaded successfully' };
|
|
|
|
|
} catch (error) {
|
|
|
|
|
reply.status(500).send({ error: error.message });
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
exports.updateProfilePicture = async (req, reply) => {
|
|
|
|
|
try {
|
|
|
|
|
const customerId = req.params.customerId;
|
|
|
|
|
const picture = new Buffer.from(req.body.picture, 'base64');
|
|
|
|
|
|
|
|
|
|
const profilePicture = await ProfilePicture.findOneAndUpdate({ customerId }, { picture }, { new: true });
|
|
|
|
|
if (!profilePicture) {
|
|
|
|
|
reply.status(404).send({ error: 'Profile picture not found' });
|
|
|
|
|
return;
|
|
|
|
|
profilePicture = new ProfilePicture({
|
|
|
|
|
customerId,
|
|
|
|
|
picture,
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
profilePicture. picture = picture;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return { message: 'Profile picture updated successfully' };
|
|
|
|
|
await profilePicture.save();
|
|
|
|
|
|
|
|
|
|
reply.send({ message: 'Profile picture uploaded successfully' });
|
|
|
|
|
} catch (error) {
|
|
|
|
|
reply.status(500).send({ error: error.message });
|
|
|
|
|
}
|
|
|
|
@ -370,3 +363,4 @@ exports.updateProfilePicture = async (req, reply) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|