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);
|
serviceSeqTracker.checkNextSeq(seq);
|
||||||
|
|
||||||
try {
|
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") {
|
if (msgDoc.from === "guest") {
|
||||||
console.log("FROM GUEST");
|
console.log("FROM GUEST");
|
||||||
// send message to owner
|
// send message to owner
|
||||||
const qrDoc = await qrDb.get(`qr_code:${msgDoc.qr_code_uri}`);
|
|
||||||
if (qrDoc.messageDeliveryMethod !== "webPush") {
|
if (qrDoc.messageDeliveryMethod !== "webPush") {
|
||||||
console.log(`Skip !webPush`);
|
console.log(`Skip !webPush`);
|
||||||
continue;
|
continue;
|
||||||
@@ -117,9 +123,6 @@ const start = async () => {
|
|||||||
for (const row of pushSubscriptionRows) {
|
for (const row of pushSubscriptionRows) {
|
||||||
try {
|
try {
|
||||||
const subscription = row.doc!.subscription;
|
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);
|
console.debug("subscription", subscription);
|
||||||
|
|
||||||
const title = limitStringLengthWithEllipsis(
|
const title = limitStringLengthWithEllipsis(
|
||||||
@@ -161,16 +164,13 @@ const start = async () => {
|
|||||||
);
|
);
|
||||||
if (error instanceof WebPushError) {
|
if (error instanceof WebPushError) {
|
||||||
if (error.body.includes("BadWebPushTopic")) {
|
if (error.body.includes("BadWebPushTopic")) {
|
||||||
console.error(
|
console.error(`Error topic=${topic}`);
|
||||||
`Error topic=chat-${msgDoc.qr_code_uri}-${msgDoc.chat}`,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (msgDoc.from === "owner") {
|
} else if (msgDoc.from === "owner") {
|
||||||
console.log("FROM OWNER");
|
console.log("FROM OWNER");
|
||||||
const qrDoc = await qrDb.get(`qr_code:${msgDoc.qr_code_uri}`);
|
|
||||||
const { rows: userChatSettingsRows } = await userChatSettingsDb.allDocs(
|
const { rows: userChatSettingsRows } = await userChatSettingsDb.allDocs(
|
||||||
{
|
{
|
||||||
startkey: `user_chat_settings:${msgDoc.qr_code_uri}:${msgDoc.chat}:guest:`,
|
startkey: `user_chat_settings:${msgDoc.qr_code_uri}:${msgDoc.chat}:guest:`,
|
||||||
@@ -204,9 +204,6 @@ const start = async () => {
|
|||||||
for (const row of subscriptionRows) {
|
for (const row of subscriptionRows) {
|
||||||
try {
|
try {
|
||||||
const subscription = row.doc!.subscription;
|
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(
|
const title = limitStringLengthWithEllipsis(
|
||||||
`Новое сообщение`,
|
`Новое сообщение`,
|
||||||
|
|||||||
Reference in New Issue
Block a user