Commit Graph

58 Commits

Author SHA1 Message Date
gnuxie 4ae5e5f63a Begin process of creating top level stores.
We now need to move the roomStateBackingStore into this thingy.
2025-03-21 16:19:08 +00:00
gnuxie 9a9547feb5 Add configuration for synapse-http-antispam. 2025-03-14 17:29:17 +00:00
gnuxie 1d413a1ab4 Include confirmation prompt listener into draupnir.
`--no-confirm` prompts will not work without this.
2025-02-28 12:19:59 +00:00
gnuxie 30ad9f098b Remove spurious error wrapping around status info. 2025-02-10 19:59:22 +00:00
gnuxie 5d727d7114 Modify 'listInfo' from status command.
This function now distinguishes between lists we are watching, lists
that are protected, and lists that we have parted from.

I don't like it. This should exist on the `PolicyRoomsManager` and
this is a complete and total mess. I don't know if there is time to
fix it yet.
2025-02-10 10:07:51 +00:00
Gnuxie acf0a406de Add functionality for config.protectAllJoinedRooms via a protection + adjacent changes. (#711)
* Initial ProtectAllJoinedRoomsProtection.

We need something like this to implement `config.protectAllJoinedRooms`,
we also need something to go alongside that removes rooms as they
are added or removed.

it will probably be a behaviour of the same protection that we will
split out.

* Move it cos i cba and we need to merge with a protection to unprotect

on leave and ban.

* IDK i keep getting distracted i need my notebook back aaaa.

* Create RoomsSetBehaviourProtection out of redundant protections.

* Add toggle for RoomsSetBehaviour.

* Enable the RoomsSetBehaviour protection by default.

* Add the behaviour protection to protections index.

* Whoopsie unprotected parted rooms should actually call itself.

* Fix bugs meow.

* handleExternalInvite -> handleExternalMembership

* Make sure leave events get propagated in bot mode.

* Add batcher to ProtectJoinedRooms component.

* Hook into handleExternalMembership for RoomsSetBehaviour.

* Remove crap from fixtures.ts

* leave all rooms when starting integration tests.

* Change how protections are informed of membership.

* Add test for Joinig and protecting rooms on invite.

* Tidy up UnprotectPartedRooms rendering.

* Update for MPS v2.7.0

Added

- Generic item batching is now available for protections to use by
  using the `StandardBatcher`.

Changed

- `Task` has been improved to be more liberal in the closures it
  accepts.  And `Task` now has more options for logging how tasks have
  failed.

- The `Protection` callback `handleExternalInvite` has been renamed to
  `handleExternalMembership`.

Fixed

- An issue where adding rooms to the protected rooms set more than
  once could sometimes cause duplicate events to be propagated.

* Fix typo mare.

* Stop protecting rooms automatically when config.protectAllJoinedRooms is false.

* Update CHANGELOG.md
2025-02-01 17:53:10 +00:00
Gnuxie 057d2c1f82 Make sure to dispose of the protected rooms set properly. (#709)
Fixes https://github.com/the-draupnir-project/Draupnir/issues/687.
2025-01-31 16:20:51 +00:00
Gnuxie bd1cf645d1 Command prefix fixes (#699)
We have added a "command normaliser" to interface-manager that can cover all the edge cases for pinging the bot or prefixing a command.

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

* Use interface-manager's command normaliser.

There's still work to be done to make sure we can get ahold of the
displyaname.

* Fetch displayname for Draupnir for the command normaliser.

* Update to interface-manager@4.0.0

This gives us the new command normaliser
2025-01-22 15:25:34 +00:00
Gnuxie fa5ce9ad9c Fix report poller (#662)
Fixes https://github.com/the-draupnir-project/Draupnir/issues/258
Fixes https://github.com/the-draupnir-project/Draupnir/issues/408
Fixes https://github.com/the-draupnir-project/Draupnir/issues/409

* Create a way to only forward reports in WebAPIs.

Honestly, I'm going to revert this because I think I have found a
better way of testing the report poller.

* Begin improving and fixing the report poller.

We need to change the ReportManager so that we can interface it out
for testing. The reason being that the report poller is inactive
in the harness and so we can't use that with a protection handle
to test. Instead I want to instantiate a report poller with
a mocked report manager.

* Update integration test nginx to mirror reports to synapse.

We need this so that we can test the report poller without needing to
do gymnastics to selectively forward reports.

* Interface out ReportManager.

Needed so we can test the report poller without doing gymnastics with
setting up fake protections.

* Fix report poller from paginating over the same reports.

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

* Revert "Create a way to only forward reports in WebAPIs."

This reverts commit 59b335f658.
We don't need this anymore.

* Update for MPS v2.4.0

Gives us the synapse admin client, updates schema, and gives us the fix for https://github.com/the-draupnir-project/Draupnir/issues/560
2025-01-10 17:06:54 +00: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
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 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 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 ed7b976404 Allow safe mode bot to respond to commands. 2024-09-17 19:15:39 +01:00
gnuxie 9959431da8 Pass the SafeModeToggle to Draupnir.
Something that is going to be broken for sure are the guages on the
appservice manager, since toggling is controlled by the base manager.

I have no idea what these guages are even for except the legacy
draupnir4all work.
2024-09-17 18:18:13 +01:00
Gnuxie 986afb7e2b Enable strictPropertyInitialization in tsconfig.json. (#541)
This will stop situations where the throttling queue was uninitialized in the Draupnir instances.

We should really enable `strict` for typescript.

The blocker for that is `useUnknownInCatchVariables` around legacy code (which should be minor).
And also `strictFunctionTypes`, which `interface-manager` exacerbates by not providing the right generics for `describeRenderer` and other methods. 

https://github.com/the-draupnir-project/Draupnir/issues/496
2024-09-09 19:15:41 +01:00
gnuxie bdbfadc095 Move to @the-draupnir-project/interface-manager for defining commands. 2024-09-06 17:18:53 +01:00
Marcel 7146216188 Fix the bot-sdk crypto by initializing the bot-sdk earlier (#512)
* Fix the bot-sdk crypto by initializing the bot-sdk earlier

Signed-off-by: MTRNord <mtrnord1@gmail.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix formatting

Signed-off-by: MTRNord <mtrnord1@gmail.com>

* Instead of moving the sync start we move the one message causing issues. This makes sure we are actually ready for incoming messages

Signed-off-by: MTRNord <mtrnord1@gmail.com>

* Add a comment on why the startupComplete method is public

---------

Signed-off-by: MTRNord <mtrnord1@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-08-17 22:55:54 +01:00
Gnuxie cc9d4cb9d5 Move to @the-draupnir-project/basic-matrix-types. (#508)
We split out some utility types from the matrix-protection-suite into a library https://github.com/the-draupnir-project/matrix-basic-types



I can't believe that like the extra lines from 

```
import {
} from ...
```

are adding up so much but whatever. 

* Move to @the-draupnir-project/basic-matrix-types.

* Whoopsie missed a test.
2024-08-16 19:12:21 +01:00
Gnuxie 337a6a3b76 Add reuse.software (#486)
We have a lot of verbose headers, and i think now is the best opportunity we have to become reuse compliant given that we just did two other similar maintenance changes (prettier, typescirpt5 & eslint9 & typescript-eslint).

* synapse_antispam resuse headers.

* delete old unused tslint.json.

* Add REUSE to pre-commit config.

* reuse info for config directory.
2024-07-25 10:58:40 +01:00
pre-commit-ci[bot] 3b2036c2db prettier all files 2024-07-22 19:13:57 +01:00
Gnuxie 8973db487b Migrate to eslint-9 flat config, typescript 5, typescript-eslint strictTypeChecked (#476)
* Migrate to eslint-9 strictTypeChecked & typescript 5.

* Update to MPS 0.23.0.

Required for strict type checks.

* Looks like we found a test that was complete garbage, amazing really.

* FIXUP

* Well, the command handler was bugged previously...

The command handler used to always only return the command
without the prefix due to an operator precedence bug.
This meant that when we made the order of operations explicit,
we were now including the prefix of the command in the copy.
So when we parsed arguments the code wasn't expecting the prefix
to be there.

* update to MPS 0.23.1.

MPS 0.23.0 was bugged because we didn't enable
`noUncheckedIndexedAccess` while upgrading to typescript 5.

* Make sure eslint runs on all ts files.

* eslint fixes.

* enable `noUncheckedIndexedAccess` & `exactOptionalPropertyTypes`.

* eslint ignores is clearly not understood by me.

* Update SuperCoolStream for eslint and ts5.

* stricter eslint done i thinks

* Whoops, added on .only somewhere.

* Update MPS.

* fix broken test realted things.

* Well I guess that part of getMessagesByUserIn was part of the interface.

* Fix redactionCommandTest.

* Account for escapeHTML in tests.

* Fix tests.

* stuff not matching with .editorconfig fixes.

* Fix appservice webAPI test.

* Update for MPS 0.23.3.
2024-07-22 16:54:04 +01:00
gnuxie 95007952fe Allow prompts to be cancelled. 2024-05-20 16:56:46 +01:00
gnuxie 1041105aa8 ProtectRoomsOnInviteProtection.
Currently creates two prompts sometimes for some reason.
We also need a way to cancel prompts see https://github.com/the-draupnir-project/Draupnir/issues/423.
Especially once we have finished protecting a room, it doesn't make sense for them to keep clicking.
2024-05-15 18:11:27 +01:00
gnuxie d1950fbb54 Update for new MPS handleExternalInvite handle. 2024-05-13 16:23:26 +01:00
gnuxie 0049dfd367 Update for MPS ProtectedRoomsManager. 2024-05-02 15:57:44 +01:00
Catalan Lover 9239c23b5d Make Draupnir refer to it self in help output. (#358)
Title is the full description of this issue. This PR fixes #357
2024-04-19 13:59:43 +01:00
gnuxie 1a3666815c Print status at startup and show a log message.
Fixes https://github.com/the-draupnir-project/Draupnir/issues/349.
2024-04-16 18:31:12 +01:00
Gnuxie ae86e173f5 Update for MPS 0.17.1. (#347)
* Update for MPS 0.17.1.

Part of https://github.com/the-draupnir-project/Draupnir/issues/333
And https://github.com/the-draupnir-project/Draupnir/issues/345

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

* Add loggableConfigTracker to Draupnir.

Part of https://github.com/the-draupnir-project/Draupnir/issues/217.
I don't think this is right yet.
2024-04-16 12:24:17 +01:00
gnuxie 16b8b5b07a Remove displayname from command handler prefixes.
It's unclear to me how to reliably implement this, so i have
removed it for now.
The problem is setting up code to watch for changes to the
displyname in the management room.
2024-04-06 20:03:36 +01:00
gnuxie b145790b16 Add capabilityMessageRender to Draupnir class. 2024-04-06 20:03:36 +01:00
gnuxie 6b9162bc9d Capability renderers and glue. 2024-04-06 20:03:36 +01:00
gnuxie 41db3392df Stop throwing in Draupnir['makeDraupnirBot'] 2024-04-06 20:03:36 +01:00
gnuxie 380f4b1a77 Update for ClientsInRoomsMap rework (MPS). 2024-04-06 20:03:36 +01:00
gnuxie 91358af874 Fix bug where report manager was only being shown 'm.room.message' 2024-04-06 20:03:36 +01:00
gnuxie 5a991897dc Fix Draupnir's joinOnInviteListener. 2024-04-06 20:03:36 +01:00
gnuxie 10905a0b29 Only inform protected rooms set of protected rooms. 2024-04-06 20:03:35 +01:00
gnuxie 426879fb68 Give commands access to MPS ClientPlatform. 2024-04-06 20:03:35 +01:00
gnuxie 34114353a8 Update for MPS ProtectionFailedToStartCB changing.
We added the protectionName to the callback.
2024-04-06 20:03:35 +01:00
gnuxie 3050fc6f22 Remove event emitter from ReportManager. 2024-04-06 20:03:34 +01:00
gnuxie fb8f76906b PromptForAccept refactor.
We had to change the old prompt for accept since it depended on the matrix emitter.
In order to remove the dependence on the event emitter, then we had to get
rid of the entire continuation which waits for the prompt and make it entirely
event driven instead.

Changes made while here were also emoji for numbres and no longer having timeout
for prompt arguments.
2024-04-06 20:03:34 +01:00
gnuxie 40f3ad4742 Try fixing prompt for accept TBC...
We need to make commands that need a prompt to fail with an error
and then we can create a prompt which basically invokes
the command again + the new argument.
2024-04-06 20:03:34 +01:00
gnuxie aeb0aedc02 Draupnir has complete ClientRooms before instantiation. 2024-04-06 20:03:34 +01:00
gnuxie e62735be0c Still messing with ClientRooms. 2024-04-06 20:03:34 +01:00
gnuxie 0a4b50634b Attempting to create DraupnirFactory. 2024-04-06 20:03:34 +01:00
gnuxie b06dcdc8bd Update protections for new consequence provider descriptions 2024-04-06 20:03:33 +01:00
gnuxie 2fd2745dc3 Update ManagementRoomOutput for MPS. 2024-04-06 20:03:33 +01:00
gnuxie f1d98b579a Port joinOnInvite listener from Mjolnir to Draupnir. 2024-04-06 20:03:33 +01:00