| 109 | * @returns profileDiff Data |
| 110 | */ |
| 111 | const fetchProfileDiff = async (profileDiffId) => { |
| 112 | try { |
| 113 | const profileDiff = await profileDiffsModel.doc(profileDiffId).get(); |
| 114 | |
| 115 | if (!profileDiff.exists) { |
| 116 | return { profileDiffExists: false }; |
| 117 | } |
| 118 | |
| 119 | const profileDiffData = profileDiff.data(); |
| 120 | const emailRedacted = profileDiffData.email ? obfuscate.obfuscateMail(profileDiffData.email) : ""; |
| 121 | const phoneRedacted = profileDiffData.phone ? obfuscate.obfuscatePhone(profileDiffData.phone) : ""; |
| 122 | |
| 123 | return { |
| 124 | id: profileDiff.id, |
| 125 | profileDiffExists: true, |
| 126 | ...profileDiffData, |
| 127 | email: emailRedacted, |
| 128 | phone: phoneRedacted, |
| 129 | }; |
| 130 | } catch (err) { |
| 131 | logger.error("Error retrieving profile Diff", err); |
| 132 | throw err; |
| 133 | } |
| 134 | }; |
| 135 | |
| 136 | /** |
| 137 | * Fetches the unobfuscated profileDiff data of the provided profileDiff Id |