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.
2020-10-12 02:46:26 -07:00
|
|
|
const dbConnection = require('./db');
|
2020-08-06 07:33:16 -07:00
|
|
|
require('dotenv').config({ path:__dirname + '/../.env' });
|
2020-10-14 12:49:18 -07:00
|
|
|
const mailer = require('./mailer');
|
2020-08-06 07:33:16 -07:00
|
|
|
|
|
|
|
async function notify() {
|
2020-10-12 02:46:26 -07:00
|
|
|
const db = await dbConnection();
|
2020-08-06 07:33:16 -07:00
|
|
|
|
|
|
|
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)
|
2020-10-14 12:49:18 -07:00
|
|
|
mailer(admin, '[Zaimki.pl] Wpisy oczekują na moderację', 'Liczba wpisów: ' + awaitingModeration);
|
2020-08-06 07:33:16 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
notify();
|