Commit Graph

25 Commits

Author SHA1 Message Date
projectmoon 6b6e59da2e Initial SQLx implementation (variables). not yet wired up to bot.
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details
- Adds migrations for the necessary tables.
 - Implements the user variables database functions.
 - Adds sqlx metadata for 'offline' use so we can build without a database.
2021-05-15 15:27:40 +00:00
projectmoon 94be4d2578 Avoid key clone when deleting variables. Minor db code cleanup.
continuous-integration/drone/push Build is passing Details
2021-02-07 21:16:58 +00:00
projectmoon 14f8bc8b39 Reuse device ID generated by matrix SDK after first login.
continuous-integration/drone/push Build is passing Details
Adds new db tree for simple global state values (which also lays
foundation for other stuff), and stores device ID in that tree after
first login. The ID is then reused on subsequent runs of the
application.

This is simpler than storing device ID in config file.

Fixes #9.
2021-02-07 14:21:28 +00:00
projectmoon a65084e04a Unit test for updating room info data.
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details
2020-11-29 21:33:46 +00:00
projectmoon 979dc8ea34 Clearer test name for clearing room info. 2020-11-29 21:29:35 +00:00
projectmoon 0b2246cbd5 Unit tests for inserting and loading room info from db. 2020-11-29 21:29:13 +00:00
projectmoon c8c38ac1d4 Avoid nested map when retrieving room info from db.
continuous-integration/drone/push Build is passing Details
2020-11-29 16:55:23 +00:00
projectmoon 224f8cd0f1 Functions for storing RoomInfo in db. Refactor bot joins room event.
continuous-integration/drone/push Build is passing Details
Add get/insert functions for RoomInfo in the rooms db.

Move 'bot joins room' code to single method, so we can also record a
RoomInfo struct into the database.
2020-11-29 14:00:05 +00:00
projectmoon 0e04e67f6e Log debug instead of trace for timestamp index inserts.
continuous-integration/drone/pr Build is passing Details
continuous-integration/drone/push Build is passing Details
2020-11-10 20:37:14 +00:00
projectmoon 551f21a49a Fix minor typo in rooms db code. 2020-11-10 20:22:26 +00:00
projectmoon 9ed2a81dd3 Record all users in room when joining.
continuous-integration/drone/pr Build is failing Details
continuous-integration/drone/push Build is failing Details
2020-11-10 20:18:00 +00:00
projectmoon fb24090952 Keep seen events in database, don't process already-seen events.
Adds a new function `should_process` to rooms impl that determines if
calling could should proceed with processing an event ID. Event IDs
are recorded (along with room ID) as a key pointing to the
system-local timestamp of when the event was received. If the key was
not originally present, we instruct calling code to process the event.

Events are also asychronously recorded by timestamp using a sled event
watcher that listens to inserts in the main tree (described above).
This secondary tree will allow easy cleanup of old events in the
future.
2020-11-09 21:16:07 +00:00
projectmoon d7aaed9e00 Implement room clearing, log to info for member updates. 2020-11-08 21:47:01 +00:00
projectmoon b5c78bcee5 Remove userandroom struct from rooms db 2020-11-08 21:47:01 +00:00
projectmoon 51ba3e3f42 Record user join/leaves in rooms. Move event emitter to its own file. 2020-11-08 21:47:01 +00:00
projectmoon 8e2f34819e Half implemented room state management foundations. 2020-11-08 21:47:01 +00:00
projectmoon bf4ce24b79 Better public API for user variables, avoid allocations in Context.
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.
2020-11-03 20:31:29 +00:00
projectmoon 7e15379c58 Migrate existing delineators to delimiter 0xfe. 2020-11-01 19:08:54 +00:00
projectmoon 9f598541fb Remove variable_count keys missed in manual data migration. 2020-10-30 22:44:19 +00:00
projectmoon 5224357f8b Add migration 2: remove old data. 2020-10-30 21:53:22 +00:00
projectmoon 6b21b0aff8 Add string name to migrations 2020-10-30 21:53:22 +00:00
projectmoon 3cec676b2f Clean up migration to make it more readable 2020-10-30 21:53:22 +00:00
projectmoon a53ce85f38 Add db migration support, change variables schema.
This is a bit of a large commit that adds basic database migration
support. It also alters the way user variables are stored in a way
requiring manual migration of existing data. The first automated
migration adds variable count in a new place.
2020-10-30 21:53:22 +00:00
projectmoon 4d9ad42bdd De-asyncify database methods 2020-10-30 21:53:22 +00:00
projectmoon 5410c53513 Split database code into separate modules. 2020-10-30 21:53:22 +00:00