Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ node_modules

# Builds
dist
dev-dist
storybook-static

# Rollup visualizer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export class MeetingInvitedNotification extends Notification<
i18nOptions
),
unsubscribe: t('notifications.common.email.unsubscribe', i18nOptions),
fcmTag: this.parameters.meetingId,
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export class MeetingStartedNotification extends Notification<
i18nOptions
),
unsubscribe: t('notifications.common.email.unsubscribe', i18nOptions),
fcmTag: this.parameters.meetingId,
}
}
}
7 changes: 7 additions & 0 deletions functions/_utils/notification/notificationBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ export abstract class Notification<
payload: {
...this.payload,
},
overrides: {
fcm: {
// Current workaround to not have duplicate push notification
// TODO : refacto when version 0.14.x (some changes on overrides and FCM integration coming)
type: 'data',
},
},
})
.catch((err) => console.error(err))
}
Expand Down
26 changes: 17 additions & 9 deletions functions/_utils/notification/notificationPayloadBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,29 @@ type NotificationDigestPayload = {
digestKey?: string | null
}

type NotificationPushPayload = {
fcmTag: string
}

type NotificationPayloadBuilder<Data extends any> = NotificationCommonPayload &
Data

export type MeetingStartedNotificationPayload =
NotificationPayloadBuilder<NotificationEmailPayload>
export type MeetingStartedNotificationPayload = NotificationPayloadBuilder<
NotificationEmailPayload & NotificationPushPayload
>

export type MeetingInvitedNotificationPayload =
NotificationPayloadBuilder<NotificationEmailPayload>
export type MeetingInvitedNotificationPayload = NotificationPayloadBuilder<
NotificationEmailPayload & NotificationPushPayload
>

export type TaskAssignedNotificationPayload =
NotificationPayloadBuilder<NotificationEmailPayload>
export type TaskAssignedNotificationPayload = NotificationPayloadBuilder<
NotificationEmailPayload & NotificationPushPayload
>

export type ThreadNotificationPayload =
NotificationPayloadBuilder<NotificationEmailPayload>
export type ThreadNotificationPayload = NotificationPayloadBuilder<
NotificationEmailPayload & NotificationPushPayload
>

export type ThreadActivityNotificationPayload = NotificationPayloadBuilder<
NotificationEmailPayload & NotificationDigestPayload
NotificationEmailPayload & NotificationDigestPayload & NotificationPushPayload
>
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export class TaskAssignedNotification extends Notification<
i18nOptions
),
unsubscribe: t('notifications.common.email.unsubscribe', i18nOptions),
fcmTag: this.parameters.taskId,
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export class ThreadActivityNotification extends Notification<
i18nOptions
),
unsubscribe: t('notifications.common.email.unsubscribe', i18nOptions),
fcmTag: `threadActivity-of-thread-${this.parameters.threadId}`,
}
}
}
1 change: 1 addition & 0 deletions functions/_utils/notification/thread/threadNotification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export class ThreadNotification extends Notification<
i18nOptions
),
unsubscribe: t('notifications.common.email.unsubscribe', i18nOptions),
fcmTag: this.parameters.threadId,
}
}
}
28 changes: 28 additions & 0 deletions functions/routes/setNovuSubscriberCredentialsWithFcmToken.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Novu, PushProviderIdEnum } from '@novu/node'
import { guardAuth } from '@utils/guardAuth'
import { guardBodyParams } from '@utils/guardBodyParams'
import { route, RouteError } from '@utils/route'
import settings from '@utils/settings'
import * as yup from 'yup'

const yupSchema = yup.object({
token: yup.string().required(),
})

export default route(async (context): Promise<void> => {
guardAuth(context)

const { token } = guardBodyParams(context, yupSchema)
if (!token || !context?.userId) {
new RouteError(400, 'Bad request')
}

const novu = new Novu(settings.novu.apiKey)
await novu.subscribers.setCredentials(
context.userId!,
PushProviderIdEnum.FCM,
{
deviceTokens: [token],
}
)
})
12 changes: 0 additions & 12 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,6 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/src/images/icon.svg" />
<link
rel="apple-touch-icon"
sizes="192x192"
href="/src/images/icon-192.png"
/>
<link
rel="apple-touch-icon"
sizes="512x512"
href="/src/images/icon-512.png"
/>
<link rel="manifest" href="/src/manifest.json" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
Expand Down
Loading