mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-07-27 04:58:24 +02:00
Major changes around events, event log, etc.
* User event log is now functional & attached to various events * Add additional missing system events * Completely re-write last_callers to have new functionality, etc. * Events.addListenerMultipleEvents() * New 'moduleInitialize' export for module init vs Event specific registerEvents * Add docs on last_callers mod
This commit is contained in:
parent
c1ae3d88ba
commit
52585c78f0
16 changed files with 392 additions and 171 deletions
|
@ -18,6 +18,7 @@ const dbs = {};
|
|||
|
||||
exports.getTransactionDatabase = getTransactionDatabase;
|
||||
exports.getModDatabasePath = getModDatabasePath;
|
||||
exports.loadDatabaseForMod = loadDatabaseForMod;
|
||||
exports.getISOTimestampString = getISOTimestampString;
|
||||
exports.sanatizeString = sanatizeString;
|
||||
exports.initializeDatabases = initializeDatabases;
|
||||
|
@ -55,6 +56,15 @@ function getModDatabasePath(moduleInfo, suffix) {
|
|||
return paths.join(conf.config.paths.modsDb, `${full}.sqlite3`);
|
||||
}
|
||||
|
||||
function loadDatabaseForMod(modInfo, cb) {
|
||||
const db = getTransactionDatabase(new sqlite3.Database(
|
||||
getModDatabasePath(modInfo),
|
||||
err => {
|
||||
return cb(err, db);
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
function getISOTimestampString(ts) {
|
||||
ts = ts || moment();
|
||||
return ts.format('YYYY-MM-DDTHH:mm:ss.SSSZ');
|
||||
|
@ -131,10 +141,11 @@ const DB_INIT_TABLE = {
|
|||
id INTEGER PRIMARY KEY,
|
||||
timestamp DATETIME NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
session_id VARCHAR NOT NULL,
|
||||
log_name VARCHAR NOT NULL,
|
||||
log_value VARCHAR NOT NULL,
|
||||
|
||||
UNIQUE(timestamp, user_id, log_name)
|
||||
UNIQUE(timestamp, user_id, session_id, log_name)
|
||||
);`
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue