Skip to content

Commit

Permalink
Add error message to journal if journal reaches dead letter queue
Browse files Browse the repository at this point in the history
nkalupahana committed Jul 1, 2024
1 parent 17fbeb1 commit 9734aeb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions scheduled-services/src/audio.ts
Original file line number Diff line number Diff line change
@@ -157,6 +157,19 @@ export const audioDeadLetter = async (req: Request, res: Response) => {
console.error(`User: ${body.user}`);
console.error(`File: ${body.file}`);
console.error(`Log: ${body.log}`);

const db = getDatabase();
const ref = db.ref(`/${body.user}/logs/${body.log}`);
let logData = await (await ref.get()).val();
logData = JSON.parse(AES.decrypt(logData.data, body.encryptionKey).toString(aesutf8));

delete logData.audio;
logData.journal = "Unable to process audio journal. If you continue to see this message, your device/browser is unable to correctly record audio.";

await ref.set({
data: AES.encrypt(JSON.stringify(logData), body.encryptionKey).toString()
});
await db.ref(`/${body.user}/offline`).set(Math.random());
} catch (e) {
console.error(e);
}

0 comments on commit 9734aeb

Please sign in to comment.