diff --git a/WHATSNEW.md b/WHATSNEW.md index e587adf8..13462252 100644 --- a/WHATSNEW.md +++ b/WHATSNEW.md @@ -3,6 +3,7 @@ This document attempts to track **major** changes and additions in ENiGMA½. For ## 0.0.12-beta * The `master` branch has become mainline. What this means to users is `git pull` will always give you the latest and greatest. Make sure to read [Updating](/docs/admin/updating.md) and keep an eye on `WHATSNEW.md` (this file) and [UPGRADE](UPGRADE.md)! See also [ticket #276](https://github.com/NuSkooler/enigma-bbs/issues/276). +* New `PV` ACS check for arbitrary user properties. See [ACS](/docs/configuration/acs.md) for details. ## 0.0.11-beta * Upgraded from `alpha` to `beta` -- The software is far along and mature enough at this point! diff --git a/core/acs_parser.js b/core/acs_parser.js index f903d6f1..9d645a2f 100644 --- a/core/acs_parser.js +++ b/core/acs_parser.js @@ -1055,6 +1055,14 @@ function peg$parse(input, options) { } const points = user.getPropertyAsNumber(UserProps.AchievementTotalPoints) || 0; return !isNan(value) && points >= value; + }, + PV : function userPropValue() { + if (!user || !Array.isArray(value) || value.length !== 2) { + return false; + } + const [propName, propValue] = value; + const actualPropValue = user.getProperty(propName); + return actualPropValue === propValue; } }[acsCode](value); } catch (e) { diff --git a/docs/configuration/acs.md b/docs/configuration/acs.md index dd57ce22..decb3267 100644 --- a/docs/configuration/acs.md +++ b/docs/configuration/acs.md @@ -39,9 +39,10 @@ The following are ACS codes available as of this writing: | APachievementPoints | User has >= _achievementPoints_ achievement points | | AFauthFactor | User's current *Authentication Factor* is >= _authFactor_. Authentication factor 1 refers to username + password (or PubKey) while factor 2 refers to 2FA such as One-Time-Password authentication. | | ARauthFactorReq | Current user **requires** an Authentication Factor >= _authFactorReq_ | +| PV[_name,_value_] | Checks that the property by _name_ for the current user is exactly _value_. This ACS allows arbitrary user property values to be checked. For example, `PV[message_conf,local]` checks that the user is currently in the "local" message conference. ## ACS Strings -ACS strings are one or more ACS codes in addition to some basic language semantics. +ACS strings are one or more ACS codes in addition to some basic language semantics. The following logical operators are supported: * `!` NOT diff --git a/misc/acs_parser.pegjs b/misc/acs_parser.pegjs index 25e5853a..5ac55f30 100644 --- a/misc/acs_parser.pegjs +++ b/misc/acs_parser.pegjs @@ -211,6 +211,14 @@ } const points = user.getPropertyAsNumber(UserProps.AchievementTotalPoints) || 0; return !isNan(value) && points >= value; + }, + PV : function userPropValue() { + if (!user || !Array.isArray(value) || value.length !== 2) { + return false; + } + const [propName, propValue] = value; + const actualPropValue = user.getProperty(propName); + return actualPropValue === propValue; } }[acsCode](value); } catch (e) {