improve message-delivery-method-web-push, change share buttons size to text-3xl
Main daploy / deploy (push) Successful in 49s
Main daploy / deploy (push) Successful in 49s
This commit is contained in:
@@ -22,7 +22,7 @@
|
|||||||
<div class="mb-8">
|
<div class="mb-8">
|
||||||
<h2 class="text-xl font-semibold mb-4">Рассказать друзьям</h2>
|
<h2 class="text-xl font-semibold mb-4">Рассказать друзьям</h2>
|
||||||
<p class="text-gray-600 mb-4">Поделитесь ссылкой на НаСвязи:</p>
|
<p class="text-gray-600 mb-4">Поделитесь ссылкой на НаСвязи:</p>
|
||||||
<div class="flex justify-center gap-4">
|
<div class="flex justify-center gap-6">
|
||||||
<!-- Telegram -->
|
<!-- Telegram -->
|
||||||
<a
|
<a
|
||||||
:href="telegramShareUrl"
|
:href="telegramShareUrl"
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
class="p-button-rounded p-button-text p-button-lg inline-flex items-center justify-center"
|
class="p-button-rounded p-button-text p-button-lg inline-flex items-center justify-center"
|
||||||
>
|
>
|
||||||
<i class="pi pi-telegram text-xl text-blue-500"></i>
|
<i class="pi pi-telegram !text-3xl text-blue-500"></i>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<!-- WhatsApp -->
|
<!-- WhatsApp -->
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
class="p-button-rounded p-button-text p-button-lg inline-flex items-center justify-center"
|
class="p-button-rounded p-button-text p-button-lg inline-flex items-center justify-center"
|
||||||
>
|
>
|
||||||
<i class="pi pi-whatsapp text-xl text-green-500"></i>
|
<i class="pi pi-whatsapp !text-3xl text-green-500"></i>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -62,40 +62,46 @@ const start = async () => {
|
|||||||
|
|
||||||
if (rows.length === 0) {
|
if (rows.length === 0) {
|
||||||
console.log("NO SUBSCRIPTIONS");
|
console.log("NO SUBSCRIPTIONS");
|
||||||
|
} else {
|
||||||
|
console.log(`sending to ${rows.length} devices`);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const row of rows) {
|
for (const row of rows) {
|
||||||
const subscription = row.doc.subscription;
|
try {
|
||||||
const topic = `chat-${msgDoc.qr_code_uri}-${msgDoc.chat}`;
|
const subscription = row.doc.subscription;
|
||||||
const tag = `${topic}-${(new Date(msgDoc.created_at).getTime() - new Date(qrDoc.created_at).getTime()).toString(36)}`;
|
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 = {
|
const options: NotificationOptions = {
|
||||||
icon: "/images/qr-code-logo-200x200.jpg",
|
icon: "/images/qr-code-logo-200x200.jpg",
|
||||||
body: msgDoc.body,
|
body: msgDoc.body,
|
||||||
tag,
|
tag,
|
||||||
requireInteraction: true,
|
requireInteraction: true,
|
||||||
data: {
|
data: {
|
||||||
url: `/manage/${msgDoc.qr_code_uri}/chat/${msgDoc.chat}`,
|
url: `/manage/${msgDoc.qr_code_uri}/chat/${msgDoc.chat}`,
|
||||||
payload: { tag },
|
payload: { tag },
|
||||||
},
|
|
||||||
} as const;
|
|
||||||
|
|
||||||
await webpush.sendNotification(
|
|
||||||
subscription,
|
|
||||||
JSON.stringify({
|
|
||||||
type: "notification",
|
|
||||||
notification: {
|
|
||||||
title: qrDoc.name,
|
|
||||||
options,
|
|
||||||
},
|
},
|
||||||
}),
|
} as const;
|
||||||
{
|
|
||||||
urgency: "high",
|
|
||||||
topic,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
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") {
|
} else if (msgDoc.from === "owner") {
|
||||||
console.log("FROM OWNER");
|
console.log("FROM OWNER");
|
||||||
|
|||||||
Reference in New Issue
Block a user