Commit Graph

415 Commits

Author SHA1 Message Date
jesopo
f363ba0607 test typo, 'sendMessaage' -> 'sendMessage' 2022-07-03 19:35:33 +00:00
jesopo
fbb66a58b3 we need to unpack obj from reportManager.on() 2022-07-03 19:34:35 +00:00
jesopo
572012190e reportManager.on() callback needs .bind(this) 2022-07-03 19:33:57 +00:00
jesopo
cc063f8b0b badUser isn't defined 2022-07-01 14:16:45 +00:00
jesopo
96f7c2f9c2 add test/intergration/reportPollingTest.ts to tsconfig.json 2022-07-01 14:11:46 +00:00
jesopo
ce78c5e6ca documentation 2022-07-01 13:29:21 +00:00
jesopo
6e7546e649 only handle reports when they pertain to a room we're protecting 2022-06-30 22:37:46 +00:00
jesopo
1b06c34fd1 remove double-schedule 2022-06-30 22:30:21 +00:00
jesopo
8df1fbc911 rebase caused duplicate ReportPoller 2022-06-30 22:28:37 +00:00
jesopo
122789ea5b wrap whole of getAbuseReports in a try/catch 2022-06-28 14:44:05 +00:00
jesopo
69f991aa9d changes lost in rebase 2022-06-27 14:13:09 +00:00
jesopo
bcf0f127d1 review feedback 2022-06-27 13:59:40 +00:00
jesopo
e0ed4fb77e document Mjolnir.reportPoll 2022-06-27 13:59:39 +00:00
jesopo
abd305cc93 (new Promise()).resolve() doesn't exist. simplify event id 2022-06-27 13:59:19 +00:00
jesopo
7049f191a6 test names 2022-06-27 13:59:19 +00:00
jesopo
0110a03b7a first draft of reportPollingTest 2022-06-27 13:59:19 +00:00
jesopo
23c3f55ceb document 'pollReports' in config 2022-06-27 13:59:19 +00:00
jesopo
5ad671ac70 else linting 2022-06-27 13:59:19 +00:00
jesopo
01e80b1dba missing } 2022-06-27 13:59:19 +00:00
jesopo
38189d3bf4 document next_token 2022-06-27 13:59:19 +00:00
jesopo
af25f831e7 don't allow schedulePoll to be called twice 2022-06-27 13:59:19 +00:00
jesopo
722c9c3774 miss return, remove promise 2022-06-27 13:59:19 +00:00
jesopo
443b59c0a3 document ReportPoll.from 2022-06-27 13:59:19 +00:00
jesopo
126791908d add (default false) option to enable report polling 2022-06-27 13:59:18 +00:00
jesopo
e518541fd0 gracefully handle setAccountData failure 2022-06-27 13:58:39 +00:00
jesopo
7dd98c0b98 switch to using event context api 2022-06-27 13:58:39 +00:00
jesopo
3c128bfeaf stop() ReportPoll in Mjolnir.stop() 2022-06-27 13:58:39 +00:00
jesopo
f3ad0e5db4 handle report poll from setting not existing 2022-06-27 13:58:39 +00:00
jesopo
f218a66c2d use .bind instead of self=this 2022-06-27 13:58:13 +00:00
jesopo
3320fee9a0 switch to setTimeout, handle exceptions 2022-06-27 13:57:45 +00:00
jesopo
3994999306 specific invalid state reasons 2022-06-27 13:57:18 +00:00
jesopo
f49f5ffbaf comments 2022-06-27 13:57:18 +00:00
jesopo
e34d542cb2 underscores for private vars are not proper 2022-06-27 13:57:18 +00:00
jesopo
fbe90ff835 copyright header 2022-06-27 13:57:18 +00:00
jesopo
682a7ec019 typo, this should have been next_token 2022-06-27 13:57:18 +00:00
jesopo
da2b5e35d5 implement polling reports in synapse 2022-06-27 13:57:17 +00:00
gnuxie
d7b846cdb3 Remove duplicated kick from kick command (merging cleanup)
Accidentally introduced while merging https://github.com/matrix-org/mjolnir/pull/291.
2022-06-15 12:34:59 +01:00
Jae Lo Presti
a876a05520
Glob kick command (#291)
This pull requests adds for glob support in the `!mjolnir kick` command.

## Example
```
!mjolnir kick @*:domain.tld <reason> --force
```
This command will kick every user having a mxid matching `domain.tld`.  
You can also still kick a particular user:
```
!mjolnir kick @user:domain.tld <reason>
```

## Tests:
Tested on the Furry Tech room (`vRGLvqJYlFvzpThbxI:matrix.org`) after a spam wave.  
It kicked over 13k bots in a matter of hours without putting too much strain on the homeserver.  
For instance, this command was matching `@spam*`:
![image](https://user-images.githubusercontent.com/76598503/167320002-f0575f50-4b54-41d1-8220-f67d72ccaf16.png)

  
  
Signed-off-by: Jae Lo Presti <me@jae.fi>
2022-06-15 12:20:27 +01:00
David Teller
0eea04bd69
A background queue for kicking (#296)
A background queue for kicking
2022-06-08 11:49:43 +02:00
Gnuxie
558cbb3cae
Remove the need to call /initialSync in getMessagesByUserIn. (#297)
* Remove the need to call `/initialSync` in `getMessagesByUserIn`.

At the moment we call `/initialSync` to give a `from` token to `/messages`.
In this PR we instead do not provide a `from` token when calling `/messages`,
which has recently been permitted in the spec
Technically this is still unstable in the spec
https://spec.matrix.org/unstable/client-server-api/#get_matrixclientv3roomsroomidmessages
https://github.com/matrix-org/matrix-spec/pull/1002

Synapse has supported this for over 2 years and Element web depends on it for threads.
https://github.com/matrix-org/matrix-js-sdk/pull/2065

Given that redactions are super heavy in Mjolnir already and have been reported
as barely functional on matrix.org I believe we should also adopt this approach as
if for some reason the spec did change before the next release (1.3) (extremely unlikely) we can revert this commit.
2022-05-24 11:16:52 +01:00
Jonathan de Jong
bf7f1318af
Improve documentation (#277)
* improve documentation

* incorperate documentation of configuration into sample file
2022-05-20 12:19:26 +01:00
David Teller
bcc3405e51
Revert "Fix traceback on Abuse Report. (#230)" (#293)
This reverts commit 27ae3ec625.
2022-05-13 15:29:49 +02:00
Marco Cirillo
27ae3ec625
Fix traceback on Abuse Report. (#230)
* Have the callback work on the packed event Obj.

And also explicitly pack the Mjolnir object inside the event.

* Add VS ignores.

* Commit suggested review changes.

- Add bind to callback
- Add type cast for event packed object

* Fix missing parenthesis.

* Don't pass Mjolnir obj to handleReport().

Co-authored-by: David Teller <davidt@element.io>
2022-05-13 15:18:30 +02:00
David Teller
74d8caa7e7
Since command: adding the ability to mute (#272) 2022-05-10 17:19:16 +02:00
gnuxie
a88fc64a07 v1.4.2 2022-05-06 11:25:49 +01:00
Jonathan de Jong
9fce35c000
Add Join Wave Short-Circuit Protection (#280)
* Add Short Circuit Protection

* fix module name

* change to dynamic timescales

* address feedback
2022-05-06 09:24:34 +01:00
Gnuxie
c8caf744c5
Apply members and server bans to the most recently active rooms first. (#274)
* Apply members and server bans to the most recently active rooms first.

https://github.com/matrix-org/mjolnir/issues/273
2022-05-03 12:36:53 +01:00
Jonathan de Jong
cc9f393ed7
fix CI (#282)
ts-mocha has also been updated to make running locally possible (else it gives a confusing error that tsconfig.json is not "json" or the likes)
2022-05-03 11:20:40 +01:00
Gnuxie
3d10f998b7
Change antispam Python module verison with mjolnir version. (#264)
The reason we want this is so that people do not forget to change the version number in the synapse module.
The precedent is that the version number has been 0.1.0 since the begging until now.
While this solution does mean that there may be new version of the module where
nothing has actually changed, this is still better than not changing the version at all.
Another version scheme for the module would be inconsistent to
the git repository tags and that has the potential to cause much more confusion
than "blank" version bumps.
If this is a problem, then antispam must be extracted to another repository.

In order to test this, run `yarn version --patch` observe the changes with `git log` and `git diff HEAD~`,
then YOU MUST delete the tag with `git tag --delete vd.d.d` when you are finished.

* more robust
2022-04-12 16:36:35 +01:00
Gnuxie
b8ee2fddbf
Synapse requires registration to be explicit (#275) 2022-04-12 12:56:27 +01:00