Skip to content

Commit 722b0ea

Browse files
authored
Merge pull request #2207 from Real-Dev-Squad/develop
Dev to main
2 parents 14fd4f4 + cd84557 commit 722b0ea

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

controllers/notify.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const admin = require("firebase-admin");
1+
const { getMessaging } = require("firebase-admin/messaging");
22
const { getFcmTokenFromUserId } = require("../services/getFcmTokenFromUserId");
33
const { getUserIdsFromRoleId } = require("../services/getUserIdsFromRoleId");
44

@@ -56,6 +56,7 @@ const notifyController = async (req, res) => {
5656
},
5757
tokens: Array.from(setOfFcmTokens),
5858
};
59+
5960
function calculateMessageSize(message) {
6061
const byteArray = new TextEncoder().encode(message);
6162

@@ -68,9 +69,9 @@ const notifyController = async (req, res) => {
6869
if (calculateMessageSize(message) >= 2) {
6970
res.error(401).send("Message length exceeds");
7071
}
71-
admin
72-
.messaging()
73-
.sendMulticast(message)
72+
73+
getMessaging()
74+
.sendEachForMulticast(message)
7475
.then(() => res.status(200).json({ status: 200, message: "User notified successfully" }))
7576
.catch((error) => {
7677
logger.error("Error sending message:", error);

models/profileDiffs.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,22 @@ const fetchProfileDiffsWithPagination = async (status, order, size, username, cu
111111
const fetchProfileDiff = async (profileDiffId) => {
112112
try {
113113
const profileDiff = await profileDiffsModel.doc(profileDiffId).get();
114-
return { id: profileDiff.id, profileDiffExists: profileDiff.exists, ...profileDiff.data() };
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+
};
115130
} catch (err) {
116131
logger.error("Error retrieving profile Diff", err);
117132
throw err;

0 commit comments

Comments
 (0)