UBERF-9551: Add web push URL (#8133)
Some checks are pending
CI / test (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / build (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / formatting (push) Blocked by required conditions
CI / uitest-pg (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / uitest-workspaces (push) Waiting to run
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions

Signed-off-by: Artem Savchenko <armisav@gmail.com>
This commit is contained in:
Artyom Savchenko 2025-03-04 19:43:06 +07:00 committed by GitHub
parent 1e134664e7
commit 885e20e8de
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 12 additions and 6 deletions

View File

@ -73,6 +73,7 @@ setMetadata(serverCore.metadata.FilesUrl, config.filesUrl)
setMetadata(serverToken.metadata.Secret, config.serverSecret)
setMetadata(serverNotification.metadata.SesUrl, config.sesUrl ?? '')
setMetadata(serverNotification.metadata.SesAuthToken, config.sesAuthToken)
setMetadata(serverNotification.metadata.WebPushUrl, config.webPushUrl ?? config.sesUrl)
setMetadata(serverTelegram.metadata.BotUrl, process.env.TELEGRAM_BOT_URL)
setMetadata(serverAiBot.metadata.EndpointURL, process.env.AI_BOT_URL)
setMetadata(serverCalendar.metadata.EndpointURL, process.env.CALENDAR_URL)

View File

@ -157,9 +157,10 @@ export async function createPushNotification (
senderAvatar?: Data<AvatarInfo>,
path?: string[]
): Promise<void> {
const sesURL: string | undefined = getMetadata(serverNotification.metadata.SesUrl)
const sesAuth: string | undefined = getMetadata(serverNotification.metadata.SesAuthToken)
if (sesURL === undefined || sesURL === '') return
const pushURL: string | undefined = getMetadata(serverNotification.metadata.WebPushUrl)
// TODO: Remove auth token after migration to new services
const authToken: string | undefined = getMetadata(serverNotification.metadata.SesAuthToken)
if (pushURL === undefined || pushURL === '') return
const userSubscriptions = subscriptions.filter((it) => target.includes(it.user))
const data: PushData = {
title,
@ -186,11 +187,11 @@ export async function createPushNotification (
}
}
void sendPushToSubscription(sesURL, sesAuth, control, target, userSubscriptions, data)
void sendPushToSubscription(pushURL, authToken, control, target, userSubscriptions, data)
}
async function sendPushToSubscription (
sesURL: string,
pushURL: string,
sesAuth: string | undefined,
control: TriggerControl,
targetUser: PersonId[],
@ -200,7 +201,7 @@ async function sendPushToSubscription (
try {
const result: Ref<PushSubscription>[] = (
await (
await fetch(concatLink(sesURL, '/web-push'), {
await fetch(concatLink(pushURL, '/web-push'), {
method: 'post',
keepalive: true,
headers: {

View File

@ -130,6 +130,7 @@ export default plugin(serverNotificationId, {
metadata: {
SesUrl: '' as Metadata<string>,
SesAuthToken: '' as Metadata<string>,
WebPushUrl: '' as Metadata<string>,
InboxOnlyNotifications: '' as Metadata<boolean>
},
class: {

View File

@ -7,6 +7,7 @@ export interface ServerEnv {
filesUrl: string | undefined
sesUrl: string | undefined
sesAuthToken: string | undefined
webPushUrl: string | undefined
accountsUrl: string
serverPort: number
enableCompression: boolean
@ -46,6 +47,7 @@ export function serverConfigFromEnv (): ServerEnv {
const filesUrl = process.env.FILES_URL
const sesUrl = process.env.SES_URL
const sesAuthToken = process.env.SES_AUTH_TOKEN
const webPushUrl = process.env.WEB_PUSH_URL
const accountsUrl = process.env.ACCOUNTS_URL
if (accountsUrl === undefined) {
@ -64,6 +66,7 @@ export function serverConfigFromEnv (): ServerEnv {
filesUrl,
sesUrl,
sesAuthToken,
webPushUrl,
accountsUrl,
serverPort,
enableCompression,