send messages to telegram from RQCP (ReadQrcodeChatPage) with link to MQCP (ManageQrcodeChatPage)
Deploy app frontend / app frontend (push) Successful in 2m43s
Deploy db-migrations / db-migrations (push) Successful in 1m8s
Deploy service message-delivery-method-web-push / service message-delivery-method-web-push (push) Successful in 1m30s
Deploy service tg-bot / service tg-bot (push) Failing after 1m54s

This commit is contained in:
2024-12-14 23:58:29 +02:00
parent 90fe585ff8
commit d71b405277
22 changed files with 396 additions and 127 deletions
@@ -62,7 +62,7 @@ export const userChatSettingsDb = new PouchDB<UserChatSettingsDocument>(
},
);
export const checkDatabases = async () => {
const checkDatabases = async () => {
const entries = await Promise.all(
Object.entries({
serverSettingsDb,
@@ -92,3 +92,5 @@ export const checkDatabases = async () => {
return Object.fromEntries(entries);
};
export const checkDatabasesPromise = checkDatabases();
@@ -9,7 +9,7 @@ import {
messagesDbUrl,
webPushSubscriptionsDb,
userChatSettingsDb,
checkDatabases,
checkDatabasesPromise,
serviceSeqTrackerDb,
} from "./dbs";
import { setupVapidDetails } from "./setupVapidDetails";
@@ -29,7 +29,7 @@ function getTopicSafe(str: string) {
}
const start = async () => {
const checkedDatabases = await checkDatabases();
const checkedDatabases = await checkDatabasesPromise;
await setupVapidDetails();
const serviceSeqTracker = await ServiceSeqTracker.Init(
@@ -47,10 +47,7 @@ const start = async () => {
heartbeat,
filter: "_selector",
selector: {
$or: [
{ type: "message" },
{ type: "service", service: "message-delivery-method-web-push" },
],
type: "message",
},
},
);
@@ -76,14 +73,14 @@ const start = async () => {
for await (const change of changesStream) {
const { seq, doc: msgDoc } = change;
if (!msgDoc) {
console.error("Change missing document:", change);
continue;
}
serviceSeqTracker.checkNextSeq(seq);
try {
if (!msgDoc) {
console.error("Change missing document:", change);
continue;
}
serviceSeqTracker.checkNextSeq(seq);
const qrDoc = await qrDb.get(`qr_code:${msgDoc.qr_code_uri}`);
const timestamp = new Date(msgDoc.created_at).getTime();
@@ -264,7 +261,7 @@ const start = async () => {
);
} catch (error) {
console.error(
`Failed processing: ${JSON.stringify(error)} change: ${JSON.stringify({ id: msgDoc._id, rev: msgDoc._rev, seq: seq })}`,
`Failed processing: ${JSON.stringify(error)} change: ${JSON.stringify({ id: msgDoc?._id, rev: msgDoc?._rev, seq: seq })}`,
);
} finally {
await serviceSeqTracker.saveSeq(seq);