@@ -0,0 +1 @@
|
|||||||
|
VITE_API_URL=https://hereconnect.condev.ru/api
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
BASE_URL=https://hereconnect.condev.ru
|
||||||
@@ -6,7 +6,7 @@ import type {
|
|||||||
WebPushSubscriptionDocument,
|
WebPushSubscriptionDocument,
|
||||||
} from '@/types/DBDocumentTypes'
|
} from '@/types/DBDocumentTypes'
|
||||||
|
|
||||||
export const qrCodeDbRemote = new PouchDB<QRCodeDocument>('https://hereconnect.condev.ru/api/qr', {
|
export const qrCodeDbRemote = new PouchDB<QRCodeDocument>(`${import.meta.env.VITE_API_URL}/qr`, {
|
||||||
skip_setup: true,
|
skip_setup: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -15,11 +15,11 @@ export const qrCodeDbLocal = new PouchDB<QRCodeDocument>('qr')
|
|||||||
export const messagesDbLocal = new PouchDB<MessageDocument>('messages')
|
export const messagesDbLocal = new PouchDB<MessageDocument>('messages')
|
||||||
|
|
||||||
export const webPushSubscriptionsDbRemote = new PouchDB<WebPushSubscriptionDocument>(
|
export const webPushSubscriptionsDbRemote = new PouchDB<WebPushSubscriptionDocument>(
|
||||||
'https://hereconnect.condev.ru/api/web_push_subscriptions',
|
`${import.meta.env.VITE_API_URL}/web_push_subscriptions`,
|
||||||
)
|
)
|
||||||
|
|
||||||
export const messagesDbRemote = new PouchDB<MessageDocument>(
|
export const messagesDbRemote = new PouchDB<MessageDocument>(
|
||||||
'https://hereconnect.condev.ru/api/messages',
|
`${import.meta.env.VITE_API_URL}/messages`,
|
||||||
{
|
{
|
||||||
skip_setup: true,
|
skip_setup: true,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export const createQrCodeDocument = async (
|
|||||||
_id: `qr_code:${uri}`,
|
_id: `qr_code:${uri}`,
|
||||||
type: 'qr_code',
|
type: 'qr_code',
|
||||||
uri,
|
uri,
|
||||||
url: `https://hereconnect.condev.ru/read/${uri}`,
|
url: `${import.meta.env.BASE_URL}/read/${uri}`,
|
||||||
user_uuid: getUserUuid(),
|
user_uuid: getUserUuid(),
|
||||||
browser_uuid: getBrowserUuid(),
|
browser_uuid: getBrowserUuid(),
|
||||||
created_at: new Date().toISOString(),
|
created_at: new Date().toISOString(),
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { createApp } from 'vue'
|
import { createApp } from 'vue'
|
||||||
import { VueQueryPlugin } from '@tanstack/vue-query'
|
import { VueQueryPlugin, type VueQueryPluginOptions } from '@tanstack/vue-query'
|
||||||
import { createPinia } from 'pinia'
|
import { createPinia } from 'pinia'
|
||||||
import PouchDB from '@/api/PouchDB'
|
import PouchDB from '@/api/PouchDB'
|
||||||
|
|
||||||
@@ -33,9 +33,19 @@ import { registerServiceWorker } from '@/registerServiceWorker'
|
|||||||
|
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
|
|
||||||
app.use(VueQueryPlugin, {
|
const vueQueryPluginOptions: VueQueryPluginOptions = {
|
||||||
enableDevtoolsV6Plugin: import.meta.env.DEV,
|
enableDevtoolsV6Plugin: import.meta.env.DEV,
|
||||||
})
|
queryClientConfig: {
|
||||||
|
defaultOptions: {
|
||||||
|
queries: {
|
||||||
|
refetchOnWindowFocus: false,
|
||||||
|
retry: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
app.use(VueQueryPlugin, vueQueryPluginOptions)
|
||||||
app.use(createPinia())
|
app.use(createPinia())
|
||||||
app.use(router)
|
app.use(router)
|
||||||
app.use(PrimeVue, {
|
app.use(PrimeVue, {
|
||||||
|
|||||||
@@ -81,7 +81,7 @@
|
|||||||
// const success = ref(false)
|
// const success = ref(false)
|
||||||
|
|
||||||
// Конфигурация для шаринга
|
// Конфигурация для шаринга
|
||||||
const siteUrl = encodeURIComponent('https://hereconnect.condev.ru')
|
const siteUrl = encodeURIComponent(import.meta.env.BASE_URL)
|
||||||
const shareText = encodeURIComponent('Попробуйте НаСвязи — удобный способ связаться через QR-код!')
|
const shareText = encodeURIComponent('Попробуйте НаСвязи — удобный способ связаться через QR-код!')
|
||||||
// const shareImage = encodeURIComponent(
|
// const shareImage = encodeURIComponent(
|
||||||
// 'https://hereconnect.condev.ru/images/qr-code-logo-200x200.jpg',
|
// 'https://hereconnect.condev.ru/images/qr-code-logo-200x200.jpg',
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
import webpush from "web-push";
|
||||||
|
import PouchDB from "./PouchDB.js";
|
||||||
|
|
||||||
|
if (!process.env.API_URL) {
|
||||||
|
throw new Error(`env API_URL is not set`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const settings = await new PouchDB(`${process.env.API_URL}/server_settings`, {
|
||||||
|
skip_setup: true,
|
||||||
|
}).get("server_settings:message_delivery_method_web_push:vapid");
|
||||||
|
|
||||||
|
webpush.setVapidDetails(
|
||||||
|
settings.vapid.subject,
|
||||||
|
settings.vapid.keys.publicKey,
|
||||||
|
settings.vapid.keys.privateKey,
|
||||||
|
);
|
||||||
|
|
||||||
|
const notification = {
|
||||||
|
type: "cancelNotification",
|
||||||
|
notification: {
|
||||||
|
title: "test",
|
||||||
|
options: {
|
||||||
|
icon: "/images/qr-code-logo-200x200.jpg",
|
||||||
|
body: "Test push message from DevTools.",
|
||||||
|
tag: "2105ef6f-3ca6-4f99-b258-0ca23f014309",
|
||||||
|
// requireInteraction: true,
|
||||||
|
// silent: false,
|
||||||
|
// vibrate: [200, 100, 200, 100, 200, 100, 200],
|
||||||
|
data: {
|
||||||
|
url: "/chat/6ilhxu/13trvu",
|
||||||
|
payload: { tag: "2105ef6f-3ca6-4f99-b258-0ca23f014309" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const { rows } = await new PouchDB(
|
||||||
|
`${process.env.API_URL}/web_push_subscriptions`,
|
||||||
|
{ skip_setup: true },
|
||||||
|
).allDocs(
|
||||||
|
process.env.WEB_PUSH_SUBSCRIPTION_ID
|
||||||
|
? {
|
||||||
|
key: process.env.WEB_PUSH_SUBSCRIPTION_ID,
|
||||||
|
include_docs: true,
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
startkey: "web_push_subscription:",
|
||||||
|
endkey: "web_push_subscription:\uFFFF",
|
||||||
|
include_docs: true,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
await Promise.allSettled(
|
||||||
|
rows.map(async ({ doc }) => {
|
||||||
|
await webpush.sendNotification(
|
||||||
|
doc.subscription,
|
||||||
|
JSON.stringify(notification),
|
||||||
|
);
|
||||||
|
console.log("sent ", doc._id);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
// issues:
|
||||||
|
// 1. NO SOUND
|
||||||
|
// 2. SAFARI NO OPEN PAGE
|
||||||
Reference in New Issue
Block a user