diff --git a/src/index.js b/src/index.js index 9fa69d76..4a657e28 100644 --- a/src/index.js +++ b/src/index.js @@ -1271,11 +1271,12 @@ fastify.post("/api/uploads_installation_TeamMember_profile/:installationId/:team const publicUrl = `https://storage.googleapis.com/${bucketName}/${filePath}`; // Always upsert the installation-level picture doc - await ProfilePictureInstall.findOneAndUpdate( - { installationId }, - { picture: publicUrl }, - { new: true, upsert: true } - ); + await ProfilePictureInstallTeamMember.findOneAndUpdate( + { installationId, teamMemberId }, + { picture: publicUrl }, + { new: true, upsert: true } +); + // Update department picture where departmentId === installationId const deptUpdate = await Deparments.findOneAndUpdate( diff --git a/src/models/store.js b/src/models/store.js index 2650e7d4..a498237e 100644 --- a/src/models/store.js +++ b/src/models/store.js @@ -258,6 +258,11 @@ const installationschema = new mongoose.Schema({ }); const profilePictureInstallTeamMemberSchema = new Schema({ + installationId: { + type: String, + unique: true, + required: true + }, teamMemberId: { type: String, unique: true,