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(serverToken.metadata.Secret, config.serverSecret)
setMetadata(serverNotification.metadata.SesUrl, config.sesUrl ?? '') setMetadata(serverNotification.metadata.SesUrl, config.sesUrl ?? '')
setMetadata(serverNotification.metadata.SesAuthToken, config.sesAuthToken) setMetadata(serverNotification.metadata.SesAuthToken, config.sesAuthToken)
setMetadata(serverNotification.metadata.WebPushUrl, config.webPushUrl ?? config.sesUrl)
setMetadata(serverTelegram.metadata.BotUrl, process.env.TELEGRAM_BOT_URL) setMetadata(serverTelegram.metadata.BotUrl, process.env.TELEGRAM_BOT_URL)
setMetadata(serverAiBot.metadata.EndpointURL, process.env.AI_BOT_URL) setMetadata(serverAiBot.metadata.EndpointURL, process.env.AI_BOT_URL)
setMetadata(serverCalendar.metadata.EndpointURL, process.env.CALENDAR_URL) setMetadata(serverCalendar.metadata.EndpointURL, process.env.CALENDAR_URL)

View File

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

View File

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

View File

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