fix tickets add reort mail and design fixes

This commit is contained in:
Thomas Demirdjian
2025-10-29 15:36:12 +01:00
parent d1be3c19a2
commit ce285881ca
35 changed files with 1069 additions and 202 deletions
+24 -19
View File
@@ -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);
+7 -1
View File
@@ -23,12 +23,18 @@ exports.onUserCreated = onDocumentCreated("users/{userID}", async (event) => {
return;
}
try {
await resendClient.emails.send({
console.log(`Sending welcome email to ${email}`);
const { data, error } = await resendClient.emails.send({
from: WELCOME_EMAIL_FROM,
to: [email],
subject: WELCOME_EMAIL_SUBJECT,
html: welcomeTemplate({ firstName, lastName }),
});
if (error) {
console.log("Failed to send welcome email:", error);
return;
}
console.log("Welcome email sent:", data);
} catch (error) {
console.log("Failed to send welcome email:", error);
}