continuous-integration/drone/push Build is passingDetails
continuous-integration/drone/pr Build is passingDetails
Instead of automatically creating a user account entry for any user
executing a command, we use an Account enum which covers both
registered and "transient" unregistered users. If a user registers,
the context has the actual user instance available, with state and
everything. If a user is unregistered, then the account is considered
transient for the request, with only the username available.
continuous-integration/drone/pr Build is passingDetails
continuous-integration/drone/push Build is passingDetails
- Adds a user_state table, currently only with active_room.
- A user must have an account to take advantage of state.
- Now, all users will get an 'account' even if they don't explicitly register.
- Bonus: converts user queries to compile-time checked macros.
To support these automatically created "accounts," the accounts table
now also has an account_status column, indicating if the user is
registered or not (or pending activation--future use).
The User model has been updated with extra properties from the state,
and the user is now carrried in the Context during command execution.
A user is ensured to be created before executing the command.
continuous-integration/drone/push Build is failingDetails
- If the room is end-to-end encrypted.
- If only the sending user and the bot are present in the room.
This lays groundwork for sensitive commands like registering a user
account with the bot.
continuous-integration/drone/push Build is passingDetails
This upgrade introduces a handful of breaking changes in the Rust
Matrix SDK.
- Some types have disappeared and changed name.
- Some functions are no longer async.
- Room display name now has a Result type instead of just returning
the value.
- Client state store has breaking changes (not really a big deal).
This required introduction of a new type to store room information
that we are interested in on the context struct. This new RoomContext
is required mostly due to unit tests, because it is no longer possible
to instantiate the Room type in the Matrix SDK.
This gives it parity with the other systems: cofd and cthulhu. More
refactoring and a rewrite later as we trend towards more
system-specific implementations.
Also comes with reorganization of the dice rolling code to centralize
the variable -> dice amount logic, and changes the way the results of
those rolls are displayed.
The database API for user variables has changed somewhat again, this
time closer to the proper vision. There are now two separate sled
Trees in the Variables struct, one for user-defined variables, and one
for counts. Keys have been changed to be username-first, then room ID.
The signatures of the functions now also use a strongly-typed struct,
UserAndRoom.
As part of this, the Context object now once again avoids allocating
new strings.
Other random changes included here:
- Remove tempfile crate in favor of sled temporary db config.
- Add bincode crate in anticipation of future (de)serializing.
This commit refactors the parsing and rolling for the dice pool system
to prepare for support of user variables. The nom parser was dropped
in favor of the easier-to-understand combine parser in most parts of
the code.
A breaking change was introduced into the dice pool syntax to allow
for proper expressions and variables. The syntax is now
"modifiers:pool-amount", e.g. "n:gnosis+8". The simple single-number
syntax with no modifiers is also still understood.
Dice pool expressions are translated into a Vec of "Amount" objects,
stored by the DicePool struct. They have an operator (+ or -) and
either a number or variable name. When the dice pool is rolled, this
list of Amonuts are is collapsed into a single number that is rolled,
as it was before the refactor.
The following changes were made to the dice rolling code:
- Store Vec<Amount> on DicePool instead of single number to roll.
- New struct RolledDicePool to store result of a dice pool roll.
- Remove Display trait from DicePool, move it over to RolledDicePool.
- Separate extra dice pool info into DicePoolModifiers.
- DicePoolModifiers is shared between DicePool and RolledDicePool.
- Dice parsing and rolling now return standard Result objects.
This commit does NOT enable support of actually using variables. Any
dice pool roll containing a variable will result in an eror.
The command parser was also rewritten to use combine and rely on the
standard Result pattern.