change topic in message-delivery-method-web-push
Deploy service message-delivery-method-web-push / service message-delivery-method-web-push (push) Successful in 1m1s
Deploy service message-delivery-method-web-push / service message-delivery-method-web-push (push) Successful in 1m1s
This commit is contained in:
@@ -75,10 +75,16 @@ const start = async () => {
|
||||
serviceSeqTracker.checkNextSeq(seq);
|
||||
|
||||
try {
|
||||
const qrDoc = await qrDb.get(`qr_code:${msgDoc.qr_code_uri}`);
|
||||
const timestamp = new Date(msgDoc.created_at).getTime();
|
||||
|
||||
const topic = `cht_${msgDoc.qr_code_uri}_${msgDoc.chat}`;
|
||||
|
||||
const tag = `${topic}_${(timestamp - new Date(qrDoc.created_at).getTime()).toString(36)}`;
|
||||
|
||||
if (msgDoc.from === "guest") {
|
||||
console.log("FROM GUEST");
|
||||
// send message to owner
|
||||
const qrDoc = await qrDb.get(`qr_code:${msgDoc.qr_code_uri}`);
|
||||
if (qrDoc.messageDeliveryMethod !== "webPush") {
|
||||
console.log(`Skip !webPush`);
|
||||
continue;
|
||||
@@ -117,9 +123,6 @@ const start = async () => {
|
||||
for (const row of pushSubscriptionRows) {
|
||||
try {
|
||||
const subscription = row.doc!.subscription;
|
||||
const topic = `chat-${msgDoc.qr_code_uri}-${msgDoc.chat}`;
|
||||
const timestamp = new Date(msgDoc.created_at).getTime();
|
||||
const tag = `${topic}-${(timestamp - new Date(qrDoc.created_at).getTime()).toString(36)}`;
|
||||
console.debug("subscription", subscription);
|
||||
|
||||
const title = limitStringLengthWithEllipsis(
|
||||
@@ -161,16 +164,13 @@ const start = async () => {
|
||||
);
|
||||
if (error instanceof WebPushError) {
|
||||
if (error.body.includes("BadWebPushTopic")) {
|
||||
console.error(
|
||||
`Error topic=chat-${msgDoc.qr_code_uri}-${msgDoc.chat}`,
|
||||
);
|
||||
console.error(`Error topic=${topic}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (msgDoc.from === "owner") {
|
||||
console.log("FROM OWNER");
|
||||
const qrDoc = await qrDb.get(`qr_code:${msgDoc.qr_code_uri}`);
|
||||
const { rows: userChatSettingsRows } = await userChatSettingsDb.allDocs(
|
||||
{
|
||||
startkey: `user_chat_settings:${msgDoc.qr_code_uri}:${msgDoc.chat}:guest:`,
|
||||
@@ -204,9 +204,6 @@ const start = async () => {
|
||||
for (const row of subscriptionRows) {
|
||||
try {
|
||||
const subscription = row.doc!.subscription;
|
||||
const topic = `chat-${msgDoc.qr_code_uri}-${msgDoc.chat}`;
|
||||
const timestamp = new Date(msgDoc.created_at).getTime();
|
||||
const tag = `${topic}-${(timestamp - new Date(qrDoc.created_at).getTime()).toString(36)}`;
|
||||
|
||||
const title = limitStringLengthWithEllipsis(
|
||||
`Новое сообщение`,
|
||||
|
||||
Reference in New Issue
Block a user