notification-issue #72
@ -9,7 +9,6 @@ const logger = getLogger();
|
|||||||
interface NotificationData {
|
interface NotificationData {
|
||||||
senderId?: string;
|
senderId?: string;
|
||||||
recipientId?: string;
|
recipientId?: string;
|
||||||
ownerId?: string;
|
|
||||||
type?: string;
|
type?: string;
|
||||||
notificationSent?: boolean;
|
notificationSent?: boolean;
|
||||||
timestamp?: admin.firestore.FieldValue;
|
timestamp?: admin.firestore.FieldValue;
|
||||||
@ -83,9 +82,6 @@ async function getUserAndFCMToken(
|
|||||||
if (notification.recipientId) {
|
if (notification.recipientId) {
|
||||||
targetUserId = notification.recipientId;
|
targetUserId = notification.recipientId;
|
||||||
logger.info(`Using top-level recipientId: ${targetUserId}`);
|
logger.info(`Using top-level recipientId: ${targetUserId}`);
|
||||||
} else if (notification.ownerId) {
|
|
||||||
targetUserId = notification.ownerId;
|
|
||||||
logger.info(`Using top-level ownerId: ${targetUserId}`);
|
|
||||||
} else if (notification.data?.userId) {
|
} else if (notification.data?.userId) {
|
||||||
targetUserId = notification.data.userId;
|
targetUserId = notification.data.userId;
|
||||||
logger.info(`Using data.userId: ${targetUserId}`);
|
logger.info(`Using data.userId: ${targetUserId}`);
|
||||||
@ -165,7 +161,6 @@ function prepareNotificationMessage(
|
|||||||
|
|
||||||
if (notification.senderId) fcmData.senderId = notification.senderId;
|
if (notification.senderId) fcmData.senderId = notification.senderId;
|
||||||
if (notification.recipientId) fcmData.recipientId = notification.recipientId;
|
if (notification.recipientId) fcmData.recipientId = notification.recipientId;
|
||||||
if (notification.ownerId) fcmData.ownerId = notification.ownerId;
|
|
||||||
if (notification.read !== undefined) fcmData.read = String(notification.read);
|
if (notification.read !== undefined) fcmData.read = String(notification.read);
|
||||||
|
|
||||||
if (notification.data) {
|
if (notification.data) {
|
||||||
@ -185,7 +180,7 @@ function prepareNotificationMessage(
|
|||||||
case "trainer_response":
|
case "trainer_response":
|
||||||
title =
|
title =
|
||||||
notification.data?.title ||
|
notification.data?.title ||
|
||||||
(notification.data?.status === "ACCEPTED"
|
(notification.data?.status === "accepted"
|
||||||
? "Trainer Request Accepted"
|
? "Trainer Request Accepted"
|
||||||
: "Trainer Request Update");
|
: "Trainer Request Update");
|
||||||
body =
|
body =
|
||||||
@ -199,14 +194,14 @@ function prepareNotificationMessage(
|
|||||||
title = notification.data?.title || "New Client Assignment";
|
title = notification.data?.title || "New Client Assignment";
|
||||||
body =
|
body =
|
||||||
notification.data?.message ||
|
notification.data?.message ||
|
||||||
`You have been assigned to ${notification.data?.name}`;
|
`You have been assigned to train ${notification.data?.name}.`;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "trainer_assigned_to_client":
|
case "trainer_assigned_to_client":
|
||||||
title = notification.data?.title || "Trainer Assigned";
|
title = notification.data?.title || "Trainer Assigned";
|
||||||
body =
|
body =
|
||||||
notification.data?.message ||
|
notification.data?.message ||
|
||||||
`${notification.data?.trainerName} has been assigned as your trainer`;
|
`${notification.data?.trainerName} has been assigned as your trainer.`;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "trainer_update_owner":
|
case "trainer_update_owner":
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user