Commit Graph

608 Commits

Author SHA1 Message Date
gnuxie b8ce84301f Throw when we're given invalid event/room ids in report forwarding.
https://github.com/the-draupnir-project/Draupnir/issues/643.
2024-12-17 23:30:26 +00:00
gnuxie f9e3bb2e5f Fix interface-manager badArgument hint.
This was printing arguments as their JSON serialized representation
rather than their text presentation.
It also couldn't handle missing arguments.

We also verified that writing the protection name wrong for the commands
will give you a message saying that the protection doesn't exist,
rather than showing the help command.
2024-12-14 14:49:23 +00:00
gnuxie a03feadb84 Sort protections by enabled and alphanumerical order in the list.
https://github.com/the-draupnir-project/planning/issues/35#issuecomment-2543127428.
2024-12-14 14:49:23 +00:00
Gnuxie ab2fb04e00 Add titles to protection setting schemas. (#639)
They are appearing as untitled when using the `protections show`
command.
2024-12-12 18:47:12 +00:00
Gnuxie 613792769f Fix protections config set/add/remove commands. (#638)
* Stop using `setSerializedValue` on protection settings.

We don't need it now that we've updated the command reader.

* Update interface-manager and MPS.

* Enable standard presentation type translators.

This will fix issues with the ban command reason.
2024-12-09 16:56:29 +00:00
Gnuxie 6f7a13ecae Improve JoinWaveShortCircuitProtection (#636)
- We add the status command that was missing and show how other protections could add their own commands to Draupnir.
- We changed the token system to use a "lazy"[^lazy] version of leaky bucket, which isn't perfect but what was happening before was the protection counted the joins in the elapsed time, and then dropped them all rather than rolling over.
- We've given it a general tidy

The reason for this is because I want to use this protection to write generic documentation (a tutorial) on how to configure protections. 

[^lazy]: "lazy" in the sense that we don't bother to remove tokens all the time, only when a token gets added, which is fine because the throughput on room joins will be tiny.
2024-12-05 12:59:16 +00:00
Gnuxie b952ee1042 Add a command to switch a protection's active capability provider. (#632)
* Add command to change the active capability provider of a protection.

* Update MPS for persistent capability set config.

The command will actually persist the chosen capabilities
across startup.
2024-12-04 12:11:06 +00:00
Gnuxie 402c39c708 Readable message for watch command when list is already watched. (#631)
https://github.com/the-draupnir-project/Draupnir/issues/630
2024-11-29 17:56:20 +00:00
Gnuxie 728089365b Unban propagation prompt now appears whenever there are room bans. (#629)
Before the prompt would only show when there were rules matching the unbanned user. Now we only decide to hide the prompt when there are no rules and no room bans.

Fixes the unban propagation side of https://github.com/the-draupnir-project/Draupnir/issues/622.
2024-11-28 16:36:12 +00:00
Gnuxie 08abad87fd Make reference to show command in the protections list command. (#628)
https://github.com/the-draupnir-project/planning/issues/35
2024-11-28 13:40:36 +00:00
gnuxie 9a62254c36 Basic protections show command.
We need to show what the documentation and structure of the protection
settings even when no config is persisted for it.
2024-11-28 12:35:23 +00:00
gnuxie 0238a76612 Update protections command for new protections config. 2024-11-27 19:34:12 +00:00
gnuxie 0ad2f0d3f2 Update draupnir factory for new protection config backends. 2024-11-27 19:34:12 +00:00
gnuxie 29e610cbee Update protections for ConfigSchema protection settings. 2024-11-27 19:34:12 +00:00
gnuxie d6b3f2e854 Always show help commands.
The interface-manager is still a little bit fragile if you give
keywords to the help command.
2024-10-11 11:24:39 +01:00
gnuxie 164434d528 Prompt for confirmation of the recover command.
Update interface-manager for `--no-confirm` handling.
Update tests for recovery confirmation.
2024-10-11 11:23:48 +01:00
Gnuxie 039f1a8ef0 Improve the information we have about the management room. (#610)
We introduce a new interface `ManagementRoomDetail`, and our implementation of this has immediate access to the room members and room state. 

Immediately, this allows us to warn when the management room is public.

In the future, it gives us a nice place to decide things like decide whether membership of the management room is enough to be considered a moderator, introduce more redundancy in access control, and give capabilities a way to determine who is a moderator (and avoid enacting consequences against them).  

* Move management room to its own folder so we can start introspecting on it.

* Add ManagementRoomDetail.ts

This is just used to track who is a moderator and whether the
management room is public.

* Update ManagementRoomOutput to depend on ManagementRoomDetail.

This should allow us to implement the feature that warns when
the management room is public.

* Send a warning if the management room is public.

Fixes https://github.com/the-draupnir-project/Draupnir/issues/413.

* Update to MPS 1.7.0 so we can get the join rule event.
2024-10-10 13:37:42 +01:00
Marcel 8b03d6448e Update matrix-appservice-bridge and use our own alias for matrix-bot-sdk (#609)
* Update matrix-appservice-bridge and use our own alias for matrix-bot-sdk

* Bump node version to support matrix-appservice-bridge

* Bump node version in CI

* Fix comments

* Add changelog entry
2024-10-10 12:11:26 +02:00
Gnuxie cb2ad995ec Suppress 'config' package's warnings when config file is missing. (#606)
Fixes https://github.com/the-draupnir-project/Draupnir/issues/480.

It's confusing people and we don't really use this package properly
or rely on it for this anyways.
2024-10-09 12:57:04 +01:00
Gnuxie 4015543f66 Filesystem config improvements (#604)
* Rename read to configRead as it should have always been.

* Got a way to extract non-default values.

Now let's try unknown configuration values.

* Show unknown property paths with a warning.

Now we just need to make this scrap available in commands.

* Remove the old Mjolnir horrible RUNTIME client.

* Make the path that is used to load the config available.

* Warn when `--draupnir-config` isn't used.

* Introduce configMeta so that we can log meta on process.exit later.

* Only show non-default config values when draupnir is exiting.

to reduce noise.

* Get consistent with logging.

So it turns out that mps4bot-sdk is using a different instance
of the bot-sdk module than Draupnir, i think.

Since we used to tell MPS's logger to use the bot-sdk's `LogService`,
but the `setLogger` that was used was obviously inconsistent with
Draupnir's.

Obviously the bot-sdk should be a peer dependency in the bot-sdk
to prevent this happening in future.
2024-10-09 11:38:24 +01:00
Gnuxie 2f9f05256c Improve recovery status message spacing (#603)
* Improve safe mode status rendering.

Feedback from @jimmackenzie.

* Update interface-manager.
2024-10-07 19:25:45 +01:00
Gnuxie 3f103cc8fa Make recovery UX clearer. (#601)
First, we make it clear how to use the recovery options in the safe mode status command:

![Screenshot_20241007_100220](https://github.com/user-attachments/assets/07f49233-6bb1-4320-80c5-ac3aa22c1ef9)


Then a recovery option is used, we show the status of the persistent config again to reinforce to the moderator that the recovery option changed something and fixed it:

![Screenshot_20241007_102045](https://github.com/user-attachments/assets/58156a56-fe17-49e1-a93a-2591dd80aaef)

https://github.com/the-draupnir-project/planning/issues/29


* Tell people how to use recovery options in safe mode status.

* Display persistent config status when a recovery option is used.
2024-10-07 10:30:53 +01:00
Catalan Lover 9cc64074e1 Rename to Draupnir in Appropriate Places (#591)
* Rename to Draupnir in Appropriate Places

* Integrate Code review feedback on CHANGELOG.md
2024-10-04 20:32:10 +02:00
Gnuxie 39eb2984c5 Display persistent configs in safe mode (#592)
* Initial attempt at this, but I don't like it.

We've managed to cnofuse rendering/command layer again just because
we started with the rendering rather than the command lol.

* Remove side effects from config renderers.

* Improve rendering of persistent configs in safe mode.

We should really also expand by default, and array properties in
details instead. Otherwise a new user might not expand by default and
might not know what's wrong.

* Remove <details> from configs themselves.

* Color blind indicators for config status.

* When config are bodged just render their reasons on the same line.

* Hide stack trace behind details.

* Update for MPS 1.6.0.
2024-10-04 17:30:05 +01:00
gnuxie 98c1822013 Give some flexibility for when to enter safe mode. 2024-10-02 11:32:04 +01:00
gnuxie bd6c3c4455 WebAPIs.stop/start method was accidentally and implicitly async, fixed.
This was leading to integration test failures on CI, when the webserver
hadn't been stopped before it was started again in tests.
2024-10-02 11:32:04 +01:00
gnuxie ba6ec9bb9a Enter safe mode by default.
However, we still need to consider whether all errors should enter
safe mode or only errors that we know are recoverable.
2024-10-02 11:32:04 +01:00
gnuxie 756d9c8491 Update DraupnirProtectedRoomsSet for more recoverable configs.
Added policy list config and protection settings.
2024-10-01 11:54:28 +01:00
gnuxie 6b0e252e2a Make StandardDraupnirManager boot into safe mode too.
Appservice bots won't boot into safe mode otherwise.
2024-09-30 12:14:00 +01:00
gnuxie 2c8c2892ba Allow safe mode to be configured in appservice mode. 2024-09-30 12:14:00 +01:00
gnuxie 3c1cb07aa6 Create a fresh safe mode instance when restarting Draupnir.
Specifically, when restart Draupnir fails, and safe mode is already
running, we will want to create a fresh safe mode instance that
contains the relevant recovery options, from the new cause of failure.
2024-09-30 12:14:00 +01:00
gnuxie 9ff0f54ff8 Automatically complete prompts from partial commands.
Fixes https://github.com/the-draupnir-project/Draupnir/issues/585.
2024-09-30 12:14:00 +01:00
gnuxie 8c74023374 Allow DraupnirSafeMode to respond to prompts. 2024-09-30 12:14:00 +01:00
gnuxie d4598d9c02 Add recover prompts to the safe mode status info. 2024-09-27 16:31:49 +01:00
gnuxie f9ff3ffdb3 Allow recover options to be used.
Now we just need to anotate the status information/command with
a partial command that calls the recover command.
2024-09-27 14:51:49 +01:00
gnuxie c556b21ac5 Display recovery options in safe mode status information. 2024-09-27 12:25:33 +01:00
gnuxie fbdd146106 Harden MentionLimitProtection after Mjolnir's introduction of the protection.
From https://github.com/matrix-org/mjolnir/pull/524.

Co-authored-by: Half-Shot <will@half-shot.uk>
2024-09-20 16:09:31 +01:00
Gnuxie 6a6e24a7b6 Verify that commands have renderers and renderers have commands (#571)
* Upgrade to interface-manager@2.4.0.

* Verify that commands have renderers and renderers have commands.

https://github.com/the-draupnir-project/Draupnir/issues/566

* Fix appservice bot's missing renderers.
2024-09-20 12:55:16 +01:00
Marcel 4658ba2e60 Add a welcome flow to Draupnir4All (#568)
* Add a welcome flow to Draupnir4All

* Fix english

Co-authored-by: Gnuxie <50846879+Gnuxie@users.noreply.github.com>

* Use invitations instead of invites

---------

Co-authored-by: Gnuxie <50846879+Gnuxie@users.noreply.github.com>
2024-09-20 09:45:26 +02:00
Marcel ee1fad567c Start draupnir bots in batches when running in appservice mode (#569)
* Start draupnir bots in batches when running in appservice mode

* Simplify and add clarity.

---------

Co-authored-by: gnuxie <Gnuxie@protonmail.com>
2024-09-20 09:44:44 +02:00
gnuxie 4c0e093c77 Fix draupnir manager for safe mode. 2024-09-19 20:12:07 +01:00
gnuxie 8f95c987ad Create a test for turning provisioned Draupnir to safe mode and back
Currently failing because the appservice draupnir manager is broken.
2024-09-19 17:52:53 +01:00
gnuxie f1a6c8cfbf Change Draupnir['start'] to be synchronous. 2024-09-19 12:46:57 +01:00
gnuxie b52948b353 Forgot to start Draupnir listening in appservice.
We need to look at Draupnir's .start method and make it `void`.
The report poller should just throw if it fails without being
caught by `Task`.

We also need to test the `toggle` in appservice in integration
tests.
2024-09-19 12:27:39 +01:00
gnuxie 334aaa7233 Give safe mode config option a better name. 2024-09-18 19:53:58 +01:00
gnuxie 35ccf94794 Make integration test harness use the BotModeToggle. 2024-09-18 18:29:49 +01:00
gnuxie a92c95a0dd Make src/index.ts use the BotModeToggle to manage the bot.
Now we need to change the integration test's makeMjolnir do the same.
2024-09-18 18:08:36 +01:00
gnuxie d82a0b0731 Print status information when booting from and to safe mode. 2024-09-18 16:19:47 +01:00
gnuxie 4db7ce3872 Find a way to print draupnir status on startup from the toggle.
without disrupting e2ee.
2024-09-18 16:04:49 +01:00
gnuxie de6e4d7416 Add restart command to safe mode.
Currently integration tests will be broken because we took control
over "who starts Draupnir?" away and gave it to the `SafeModeToggle`.

So we need to fix that.
2024-09-18 15:28:05 +01:00