Add helper function to purge notifications

This commit is contained in:
D. Berge
2023-10-14 19:54:34 +02:00
parent 66ec28dd83
commit ed1da11c9d

View File

@@ -1,6 +1,18 @@
const { makeSubscriber, pool } = require('./connection'); const { makeSubscriber, pool } = require('./connection');
const { ALERT, ERROR, WARNING, NOTICE, INFO, DEBUG } = require('DOUGAL_ROOT/debug')(__filename); const { ALERT, ERROR, WARNING, NOTICE, INFO, DEBUG } = require('DOUGAL_ROOT/debug')(__filename);
async function purge () {
DEBUG("Purging old notifications");
const client = await pool.connect();
try {
await client.query("CALL purge_notifications();");
} catch (err) {
ERROR(err);
} finally {
client.release();
}
}
async function fullPayload (payload) { async function fullPayload (payload) {
if (!payload.payload_id) { if (!payload.payload_id) {
@@ -58,5 +70,6 @@ async function listen (addChannels, callback) {
} }
module.exports = { module.exports = {
listen listen,
purge
}; };