Commit Graph

24 Commits

Author SHA1 Message Date
projectmoon 896acee5ba Avoid cloned command input with From<String> instead of From<&str>. 2021-05-27 15:50:43 +00:00
projectmoon 4ae871224a Remove ExecutionError, as it is unnecessary. 2021-05-26 21:25:32 +00:00
projectmoon 8f5b6f0636 Replace db query with simple in-memory check of if account already exists. 2021-05-26 21:04:53 +00:00
projectmoon 5b3d174edc Separate registering and linking accounts.
Can register an account with the bot to manage variables and stuff in
private room, and then separately "link" it with a password, which
makes it available to anything using the bot API (aka web app). Can
also unlink and unregister. Check command no longer validates
password. It just checks and reports your account status.
2021-05-26 15:28:59 +00:00
projectmoon b05129ad9f Localize all command parsing code into trait impls.
This cleans up the command parser a lot, as all of the one or two line
functions and associated imports have been removed. Unfortunately it
does make the command files larger, as two trait impls are required:
one for converting to Box<dyn Command>, and one for converting from
&str to the command type.

Fixes #66.
2021-05-25 23:55:50 +00:00
projectmoon 5d002e5063 Add ability to store user active room, with skeleton accounts.
- 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.
2021-05-25 22:29:01 +00:00
projectmoon 395753e8a9 Remove room state mgmt; let matrix SDK do it on-demand instead.
Fixes #71.

Fixes #20.
2021-05-24 21:45:51 +00:00
projectmoon df0248d99a More useful account registration message. 2021-05-23 13:58:58 +00:00
projectmoon 76214bc790 Add an account deletion command. 2021-05-22 23:12:17 +00:00
projectmoon 926dae57fb Add check password command. 2021-05-22 22:25:00 +00:00
projectmoon ca34841d86 Functional user account registration. 2021-05-22 14:52:32 +00:00
projectmoon c1ec7366e4 Add user accounts, registration command, secure command valiation. 2021-05-22 14:01:16 +00:00
projectmoon 9de74d05a9 Add an is_secure attribute for commands. 2021-05-21 15:32:08 +00:00
projectmoon 8e4eb574d2 Update to latest matrix SDK and other dependencies. 2021-03-15 20:10:42 +00:00
projectmoon 304c91c69d Rename CommandResult to ExecutionResult 2021-02-07 21:39:21 +00:00
projectmoon b3c4d8a38c Centralize plain text formatting at point of message sending.
Instead of relying on all parts of the application to construct both
HTML and plain-text responses, we now construct only HTML responses,
and convert the HTML to plain text right before sending the message to
Matrix.

This is a first iteration, because the plain text has a few extra
newlines than it should, created by use of nested <p> tags.
2021-01-31 14:12:09 +00:00
projectmoon 16eb87e50f Convert command execution to use results. 2021-01-30 14:28:14 +00:00
projectmoon 1b0003ff1b Upgrade to Matrix SDK latest (Store Rewrite) and Tokio 1.0
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.
2021-01-30 12:54:47 +00:00
projectmoon e177da9c25 Centralize record_room_information function. 2020-11-30 19:53:26 +00:00
projectmoon 7e1abab66d Resync command now uses record_room_information. 2020-11-29 21:18:41 +00:00
projectmoon 569ba4f2e0 Carry full room instance in context instead of just room id. 2020-11-29 21:03:45 +00:00
projectmoon 68db038336 Properly avoid allocation for our_username in resync command. 2020-11-23 19:54:20 +00:00
projectmoon 18352c8c19 Filter out our username when resyncing (with an allocation). 2020-11-22 22:13:11 +00:00
projectmoon dda0d74f45 Implement resync command without filtering ourselves out. 2020-11-22 21:30:24 +00:00