This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Zaimki/server/notify.js

23 lines
721 B
JavaScript
Raw Normal View History

2020-10-12 02:46:26 -07:00
const dbConnection = require('./db');
require('dotenv').config({ path:__dirname + '/../.env' });
const mailer = require('./mailer');
async function notify() {
2020-10-12 02:46:26 -07:00
const db = await dbConnection();
const awaitingModeration = (await db.get(`SELECT count(*) as c FROM nouns WHERE approved = 0`)).c;
if (!awaitingModeration) {
console.log('No entries awaiting moderation');
return;
}
console.log('Entries awaiting moderation: ' + awaitingModeration);
for (let admin of process.env.MAILER_ADMINS.split(',')) {
console.log('Sending email to ' + admin)
mailer(admin, '[Zaimki.pl] Wpisy oczekują na moderację', 'Liczba wpisów: ' + awaitingModeration);
}
}
notify();