fix tickets add reort mail and design fixes
This commit is contained in:
@@ -27,6 +27,7 @@ exports.sendNotificationWhenDocIsCreated = onDocumentCreated(
|
||||
receiverCollection = "users",
|
||||
message = "",
|
||||
data: notifData = {},
|
||||
mailOnly = false,
|
||||
} = event.data.data();
|
||||
|
||||
if (!receiver || !message) {
|
||||
@@ -40,27 +41,29 @@ exports.sendNotificationWhenDocIsCreated = onDocumentCreated(
|
||||
emailNotifications = false,
|
||||
} = (await db.collection(receiverCollection).doc(receiver).get()).data();
|
||||
|
||||
const tokensSet = new Set(
|
||||
[]
|
||||
.concat(Array.isArray(pushTokens) ? pushTokens : [])
|
||||
.concat(pushToken ? [pushToken] : [])
|
||||
.filter(Boolean),
|
||||
);
|
||||
const tokens = Array.from(tokensSet);
|
||||
if (!mailOnly) {
|
||||
const tokensSet = new Set(
|
||||
[]
|
||||
.concat(Array.isArray(pushTokens) ? pushTokens : [])
|
||||
.concat(pushToken ? [pushToken] : [])
|
||||
.filter(Boolean),
|
||||
);
|
||||
const tokens = Array.from(tokensSet);
|
||||
|
||||
if (!tokens?.length) {
|
||||
console.warn("User push token not found");
|
||||
return null;
|
||||
if (!tokens?.length) {
|
||||
console.warn("User push token not found");
|
||||
return null;
|
||||
}
|
||||
|
||||
await sendExpoNotification({
|
||||
tokens,
|
||||
receiverId: receiver,
|
||||
receiverCollection,
|
||||
title: title || "MusicLand",
|
||||
message: message,
|
||||
data: notifData || {},
|
||||
});
|
||||
}
|
||||
|
||||
await sendExpoNotification({
|
||||
tokens,
|
||||
receiverId: receiver,
|
||||
receiverCollection,
|
||||
title: title || "MusicLand",
|
||||
message: message,
|
||||
data: notifData || {},
|
||||
});
|
||||
if (emailNotifications && !!email) {
|
||||
try {
|
||||
if (!email) {
|
||||
@@ -219,6 +222,7 @@ const sendNotification = async ({
|
||||
receiverCollection = "users",
|
||||
title = "",
|
||||
message = null,
|
||||
mailOnly = false,
|
||||
data = {},
|
||||
}) => {
|
||||
try {
|
||||
@@ -234,6 +238,7 @@ const sendNotification = async ({
|
||||
time: admin.firestore.FieldValue.serverTimestamp(),
|
||||
read: false,
|
||||
readAt: null,
|
||||
mailOnly,
|
||||
data,
|
||||
};
|
||||
const { id } = await refList.notifications.add(payload);
|
||||
|
||||
Reference in New Issue
Block a user