From a393a195d052e42473c28924355b61492fb83154 Mon Sep 17 00:00:00 2001 From: Vasilii Mikhailovskii Date: Fri, 29 Nov 2024 00:23:48 +0200 Subject: [PATCH] improve message-delivery-method-web-push, change share buttons size to text-3xl --- apps/frontend/src/views/DonateView.vue | 6 +- .../src/server.ts | 62 ++++++++++--------- 2 files changed, 37 insertions(+), 31 deletions(-) diff --git a/apps/frontend/src/views/DonateView.vue b/apps/frontend/src/views/DonateView.vue index 27036ed..145f400 100644 --- a/apps/frontend/src/views/DonateView.vue +++ b/apps/frontend/src/views/DonateView.vue @@ -22,7 +22,7 @@

Рассказать друзьям

Поделитесь ссылкой на НаСвязи:

-
+
- + @@ -40,7 +40,7 @@ rel="noopener noreferrer" class="p-button-rounded p-button-text p-button-lg inline-flex items-center justify-center" > - +
diff --git a/services/message-delivery-method-web-push/src/server.ts b/services/message-delivery-method-web-push/src/server.ts index 5603caf..2f3b40c 100644 --- a/services/message-delivery-method-web-push/src/server.ts +++ b/services/message-delivery-method-web-push/src/server.ts @@ -62,40 +62,46 @@ const start = async () => { if (rows.length === 0) { console.log("NO SUBSCRIPTIONS"); + } else { + console.log(`sending to ${rows.length} devices`); } for (const row of rows) { - const subscription = row.doc.subscription; - const topic = `chat-${msgDoc.qr_code_uri}-${msgDoc.chat}`; - const tag = `${topic}-${(new Date(msgDoc.created_at).getTime() - new Date(qrDoc.created_at).getTime()).toString(36)}`; + try { + const subscription = row.doc.subscription; + const topic = `chat-${msgDoc.qr_code_uri}-${msgDoc.chat}`; + const tag = `${topic}-${(new Date(msgDoc.created_at).getTime() - new Date(qrDoc.created_at).getTime()).toString(36)}`; - const options: NotificationOptions = { - icon: "/images/qr-code-logo-200x200.jpg", - body: msgDoc.body, - tag, - requireInteraction: true, - data: { - url: `/manage/${msgDoc.qr_code_uri}/chat/${msgDoc.chat}`, - payload: { tag }, - }, - } as const; - - await webpush.sendNotification( - subscription, - JSON.stringify({ - type: "notification", - notification: { - title: qrDoc.name, - options, + const options: NotificationOptions = { + icon: "/images/qr-code-logo-200x200.jpg", + body: msgDoc.body, + tag, + requireInteraction: true, + data: { + url: `/manage/${msgDoc.qr_code_uri}/chat/${msgDoc.chat}`, + payload: { tag }, }, - }), - { - urgency: "high", - topic, - }, - ); + } as const; - console.log("sent"); + await webpush.sendNotification( + subscription, + JSON.stringify({ + type: "notification", + notification: { + title: qrDoc.name, + options, + }, + }), + { + urgency: "high", + topic, + }, + ); + } catch (error) { + console.error( + `Error sending notification to ${row.id} - ${JSON.stringify(error)}`, + ); + } } } else if (msgDoc.from === "owner") { console.log("FROM OWNER");