mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-07-24 11:38:27 +02:00
* New ACS class avail @ client.acs
* Experimental / WIP work on issue #79 * Issue # 77: Changes to new_scan.js, temp conf/area swapping, etc. * message area: getMessageConfByAreaTag(), getMessageConfTagByAreaTag(), tempChangeMessageConfAndArea(), getNewMessageCountInAreaForUser()
This commit is contained in:
parent
2baf028e34
commit
8bd61f2d01
6 changed files with 262 additions and 113 deletions
53
core/acs.js
Normal file
53
core/acs.js
Normal file
|
@ -0,0 +1,53 @@
|
|||
/* jslint node: true */
|
||||
'use strict';
|
||||
|
||||
// ENiGMA½
|
||||
const checkAcs = require('./acs_parser.js').parse;
|
||||
|
||||
// deps
|
||||
const assert = require('assert');
|
||||
const _ = require('lodash');
|
||||
|
||||
class ACS {
|
||||
constructor(client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
check(acs, scope, defaultAcs) {
|
||||
acs = acs ? acs[scope] : defaultAcs;
|
||||
acs = acs || defaultAcs;
|
||||
return checkAcs(acs, { client : this.client } );
|
||||
}
|
||||
|
||||
hasMessageConfRead(conf) {
|
||||
return this.check(conf.acs, 'read', ACS.Defaults.MessageConfRead);
|
||||
}
|
||||
|
||||
hasMessageAreaRead(area) {
|
||||
return this.check(area.acs, 'read', ACS.Defaults.MessageAreaRead);
|
||||
}
|
||||
|
||||
getConditionalValue(condArray, memberName) {
|
||||
assert(_.isArray(condArray));
|
||||
assert(_.isString(memberName));
|
||||
|
||||
const matchCond = condArray.find( cond => {
|
||||
if(_.has(cond, 'acs')) {
|
||||
return checkAcs(cond.acs, { client : this.client } );
|
||||
} else {
|
||||
return true; // no acs check req.
|
||||
}
|
||||
});
|
||||
|
||||
if(matchCond) {
|
||||
return matchCond[memberName];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ACS.Defaults = {
|
||||
MessageAreaRead : 'GM[users]',
|
||||
MessageConfRead : 'GM[users]',
|
||||
};
|
||||
|
||||
module.exports = ACS;
|
Loading…
Add table
Add a link
Reference in a new issue