···11+# Mjolnir (Matrix Moderation Tool) {#module-services-mjolnir}
22+33+This chapter will show you how to set up your own, self-hosted
44+[Mjolnir](https://github.com/matrix-org/mjolnir) instance.
55+66+As an all-in-one moderation tool, it can protect your server from
77+malicious invites, spam messages, and whatever else you don't want.
88+In addition to server-level protection, Mjolnir is great for communities
99+wanting to protect their rooms without having to use their personal
1010+accounts for moderation.
1111+1212+The bot by default includes support for bans, redactions, anti-spam,
1313+server ACLs, room directory changes, room alias transfers, account
1414+deactivation, room shutdown, and more.
1515+1616+See the [README](https://github.com/matrix-org/mjolnir#readme)
1717+page and the [Moderator's guide](https://github.com/matrix-org/mjolnir/blob/main/docs/moderators.md)
1818+for additional instructions on how to setup and use Mjolnir.
1919+2020+For [additional settings](#opt-services.mjolnir.settings)
2121+see [the default configuration](https://github.com/matrix-org/mjolnir/blob/main/config/default.yaml).
2222+2323+## Mjolnir Setup {#module-services-mjolnir-setup}
2424+2525+First create a new Room which will be used as a management room for Mjolnir. In
2626+this room, Mjolnir will log possible errors and debugging information. You'll
2727+need to set this Room-ID in [services.mjolnir.managementRoom](#opt-services.mjolnir.managementRoom).
2828+2929+Next, create a new user for Mjolnir on your homeserver, if not present already.
3030+3131+The Mjolnir Matrix user expects to be free of any rate limiting.
3232+See [Synapse #6286](https://github.com/matrix-org/synapse/issues/6286)
3333+for an example on how to achieve this.
3434+3535+If you want Mjolnir to be able to deactivate users, move room aliases, shutdown rooms, etc.
3636+you'll need to make the Mjolnir user a Matrix server admin.
3737+3838+Now invite the Mjolnir user to the management room.
3939+4040+It is recommended to use [Pantalaimon](https://github.com/matrix-org/pantalaimon),
4141+so your management room can be encrypted. This also applies if you are looking to moderate an encrypted room.
4242+4343+To enable the Pantalaimon E2E Proxy for mjolnir, enable
4444+[services.mjolnir.pantalaimon](#opt-services.mjolnir.pantalaimon.enable). This will
4545+autoconfigure a new Pantalaimon instance, which will connect to the homeserver
4646+set in [services.mjolnir.homeserverUrl](#opt-services.mjolnir.homeserverUrl) and Mjolnir itself
4747+will be configured to connect to the new Pantalaimon instance.
4848+4949+```
5050+{
5151+ services.mjolnir = {
5252+ enable = true;
5353+ homeserverUrl = "https://matrix.domain.tld";
5454+ pantalaimon = {
5555+ enable = true;
5656+ username = "mjolnir";
5757+ passwordFile = "/run/secrets/mjolnir-password";
5858+ };
5959+ protectedRooms = [
6060+ "https://matrix.to/#/!xxx:domain.tld"
6161+ ];
6262+ managementRoom = "!yyy:domain.tld";
6363+ };
6464+}
6565+```
6666+6767+### Element Matrix Services (EMS) {#module-services-mjolnir-setup-ems}
6868+6969+If you are using a managed ["Element Matrix Services (EMS)"](https://ems.element.io/)
7070+server, you will need to consent to the terms and conditions. Upon startup, an error
7171+log entry with a URL to the consent page will be generated.
7272+7373+## Synapse Antispam Module {#module-services-mjolnir-matrix-synapse-antispam}
7474+7575+A Synapse module is also available to apply the same rulesets the bot
7676+uses across an entire homeserver.
7777+7878+To use the Antispam Module, add `matrix-synapse-plugins.matrix-synapse-mjolnir-antispam`
7979+to the Synapse plugin list and enable the `mjolnir.Module` module.
8080+8181+```
8282+{
8383+ services.matrix-synapse = {
8484+ plugins = with pkgs; [
8585+ matrix-synapse-plugins.matrix-synapse-mjolnir-antispam
8686+ ];
8787+ extraConfig = ''
8888+ modules:
8989+ - module: mjolnir.Module
9090+ config:
9191+ # Prevent servers/users in the ban lists from inviting users on this
9292+ # server to rooms. Default true.
9393+ block_invites: true
9494+ # Flag messages sent by servers/users in the ban lists as spam. Currently
9595+ # this means that spammy messages will appear as empty to users. Default
9696+ # false.
9797+ block_messages: false
9898+ # Remove users from the user directory search by filtering matrix IDs and
9999+ # display names by the entries in the user ban list. Default false.
100100+ block_usernames: false
101101+ # The room IDs of the ban lists to honour. Unlike other parts of Mjolnir,
102102+ # this list cannot be room aliases or permalinks. This server is expected
103103+ # to already be joined to the room - Mjolnir will not automatically join
104104+ # these rooms.
105105+ ban_lists:
106106+ - "!roomid:example.org"
107107+ '';
108108+ };
109109+}
110110+```
+2
nixos/modules/services/matrix/mjolnir.nix
···236236 };
237237238238 meta = {
239239+ # Don't edit the docbook xml directly, edit the md and generate it:
240240+ # `pandoc mjolnir.md -t docbook --top-level-division=chapter --extract-media=media -f markdown-smart --lua-filter ../../../../doc/build-aux/pandoc-filters/myst-reader/roles.lua --lua-filter ../../../../doc/build-aux/pandoc-filters/docbook-writer/rst-roles.lua > mjolnir.xml`
239241 doc = ./mjolnir.xml;
240242 maintainers = with maintainers; [ jojosch ];
241243 };
+96-84
nixos/modules/services/matrix/mjolnir.xml
···11-<chapter xmlns="http://docbook.org/ns/docbook"
22- xmlns:xlink="http://www.w3.org/1999/xlink"
33- xmlns:xi="http://www.w3.org/2001/XInclude"
44- version="5.0"
55- xml:id="module-services-mjolnir">
66- <title>Mjolnir (Matrix Moderation Tool)</title>
77- <para>
88- This chapter will show you how to set up your own, self-hosted
99- <link xlink:href="https://github.com/matrix-org/mjolnir">Mjolnir</link>
1010- instance.
1111- </para>
1212- <para>
1313- As an all-in-one moderation tool, it can protect your server from
1414- malicious invites, spam messages, and whatever else you don't want.
1515- In addition to server-level protection, Mjolnir is great for communities
1616- wanting to protect their rooms without having to use their personal
1717- accounts for moderation.
1818- </para>
1919- <para>
2020- The bot by default includes support for bans, redactions, anti-spam,
2121- server ACLs, room directory changes, room alias transfers, account
2222- deactivation, room shutdown, and more.
2323- </para>
2424- <para>
2525- See the <link xlink:href="https://github.com/matrix-org/mjolnir#readme">README</link>
2626- page and the <link xlink:href="https://github.com/matrix-org/mjolnir/blob/main/docs/moderators.md">Moderator's guide</link>
2727- for additional instructions on how to setup and use Mjolnir.
2828- </para>
2929- <para>
3030- For <link linkend="opt-services.mjolnir.settings">additional settings</link>
3131- see <link xlink:href="https://github.com/matrix-org/mjolnir/blob/main/config/default.yaml">the default configuration</link>.
3232- </para>
3333- <section xml:id="module-services-mjolnir-setup">
3434- <title>Mjolnir Setup</title>
11+<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="module-services-mjolnir">
22+ <title>Mjolnir (Matrix Moderation Tool)</title>
353 <para>
3636- First create a new Room which will be used as a management room for Mjolnir. In
3737- this room, Mjolnir will log possible errors and debugging information. You'll
3838- need to set this Room-ID in <link linkend="opt-services.mjolnir.managementRoom">services.mjolnir.managementRoom</link>.
3939- </para>
4040- <para>
4141- Next, create a new user for Mjolnir on your homeserver, if not present already.
4242- </para>
4343- <para>
4444- The Mjolnir Matrix user expects to be free of any rate limiting.
4545- See <link xlink:href="https://github.com/matrix-org/synapse/issues/6286">Synapse #6286</link>
4646- for an example on how to achieve this.
44+ This chapter will show you how to set up your own, self-hosted
55+ <link xlink:href="https://github.com/matrix-org/mjolnir">Mjolnir</link>
66+ instance.
477 </para>
488 <para>
4949- If you want Mjolnir to be able to deactivate users, move room aliases, shutdown rooms, etc.
5050- you'll need to make the Mjolnir user a Matrix server admin.
99+ As an all-in-one moderation tool, it can protect your server from
1010+ malicious invites, spam messages, and whatever else you don't want.
1111+ In addition to server-level protection, Mjolnir is great for
1212+ communities wanting to protect their rooms without having to use
1313+ their personal accounts for moderation.
5114 </para>
5215 <para>
5353- Now invite the Mjolnir user to the management room.
1616+ The bot by default includes support for bans, redactions, anti-spam,
1717+ server ACLs, room directory changes, room alias transfers, account
1818+ deactivation, room shutdown, and more.
5419 </para>
5520 <para>
5656- It is recommended to use <link xlink:href="https://github.com/matrix-org/pantalaimon">Pantalaimon</link>,
5757- so your management room can be encrypted. This also applies if you are looking to moderate an encrypted room.
2121+ See the
2222+ <link xlink:href="https://github.com/matrix-org/mjolnir#readme">README</link>
2323+ page and the
2424+ <link xlink:href="https://github.com/matrix-org/mjolnir/blob/main/docs/moderators.md">Moderator's
2525+ guide</link> for additional instructions on how to setup and use
2626+ Mjolnir.
5827 </para>
5928 <para>
6060- To enable the Pantalaimon E2E Proxy for mjolnir, enable
6161- <link linkend="opt-services.mjolnir.pantalaimon.enable">services.mjolnir.pantalaimon</link>. This will
6262- autoconfigure a new Pantalaimon instance, which will connect to the homeserver
6363- set in <link linkend="opt-services.mjolnir.homeserverUrl">services.mjolnir.homeserverUrl</link> and Mjolnir itself
6464- will be configured to connect to the new Pantalaimon instance.
2929+ For <link linkend="opt-services.mjolnir.settings">additional
3030+ settings</link> see
3131+ <link xlink:href="https://github.com/matrix-org/mjolnir/blob/main/config/default.yaml">the
3232+ default configuration</link>.
6533 </para>
6666-<programlisting>
3434+ <section xml:id="module-services-mjolnir-setup">
3535+ <title>Mjolnir Setup</title>
3636+ <para>
3737+ First create a new Room which will be used as a management room
3838+ for Mjolnir. In this room, Mjolnir will log possible errors and
3939+ debugging information. You'll need to set this Room-ID in
4040+ <link linkend="opt-services.mjolnir.managementRoom">services.mjolnir.managementRoom</link>.
4141+ </para>
4242+ <para>
4343+ Next, create a new user for Mjolnir on your homeserver, if not
4444+ present already.
4545+ </para>
4646+ <para>
4747+ The Mjolnir Matrix user expects to be free of any rate limiting.
4848+ See
4949+ <link xlink:href="https://github.com/matrix-org/synapse/issues/6286">Synapse
5050+ #6286</link> for an example on how to achieve this.
5151+ </para>
5252+ <para>
5353+ If you want Mjolnir to be able to deactivate users, move room
5454+ aliases, shutdown rooms, etc. you'll need to make the Mjolnir user
5555+ a Matrix server admin.
5656+ </para>
5757+ <para>
5858+ Now invite the Mjolnir user to the management room.
5959+ </para>
6060+ <para>
6161+ It is recommended to use
6262+ <link xlink:href="https://github.com/matrix-org/pantalaimon">Pantalaimon</link>,
6363+ so your management room can be encrypted. This also applies if you
6464+ are looking to moderate an encrypted room.
6565+ </para>
6666+ <para>
6767+ To enable the Pantalaimon E2E Proxy for mjolnir, enable
6868+ <link linkend="opt-services.mjolnir.pantalaimon.enable">services.mjolnir.pantalaimon</link>.
6969+ This will autoconfigure a new Pantalaimon instance, which will
7070+ connect to the homeserver set in
7171+ <link linkend="opt-services.mjolnir.homeserverUrl">services.mjolnir.homeserverUrl</link>
7272+ and Mjolnir itself will be configured to connect to the new
7373+ Pantalaimon instance.
7474+ </para>
7575+ <programlisting>
6776{
6877 services.mjolnir = {
6978 enable = true;
7070- homeserverUrl = "https://matrix.domain.tld";
7979+ homeserverUrl = "https://matrix.domain.tld";
7180 pantalaimon = {
7281 enable = true;
7373- username = "mjolnir";
7474- passwordFile = "/run/secrets/mjolnir-password";
8282+ username = "mjolnir";
8383+ passwordFile = "/run/secrets/mjolnir-password";
7584 };
7685 protectedRooms = [
7777- "https://matrix.to/#/!xxx:domain.tld"
8686+ "https://matrix.to/#/!xxx:domain.tld"
7887 ];
7979- managementRoom = "!yyy:domain.tld";
8888+ managementRoom = "!yyy:domain.tld";
8089 };
8190}
8291</programlisting>
8383- <section xml:id="module-services-mjolnir-setup-ems">
8484- <title>Element Matrix Services (EMS)</title>
8585- <para>
8686- If you are using a managed <link xlink:href="https://ems.element.io/">"Element Matrix Services (EMS)"</link>
8787- server, you will need to consent to the terms and conditions. Upon startup, an error
8888- log entry with a URL to the consent page will be generated.
8989- </para>
9090- </section>
9191- </section>
9292-9393- <section xml:id="module-services-mjolnir-matrix-synapse-antispam">
9494- <title>Synapse Antispam Module</title>
9595- <para>
9696- A Synapse module is also available to apply the same rulesets the bot
9797- uses across an entire homeserver.
9898- </para>
9999- <para>
100100- To use the Antispam Module, add <literal>matrix-synapse-plugins.matrix-synapse-mjolnir-antispam</literal>
101101- to the Synapse plugin list and enable the <literal>mjolnir.Module</literal> module.
102102- </para>
103103-<programlisting>
9292+ <section xml:id="module-services-mjolnir-setup-ems">
9393+ <title>Element Matrix Services (EMS)</title>
9494+ <para>
9595+ If you are using a managed
9696+ <link xlink:href="https://ems.element.io/">"Element Matrix
9797+ Services (EMS)"</link> server, you will need to consent to
9898+ the terms and conditions. Upon startup, an error log entry with
9999+ a URL to the consent page will be generated.
100100+ </para>
101101+ </section>
102102+ </section>
103103+ <section xml:id="module-services-mjolnir-matrix-synapse-antispam">
104104+ <title>Synapse Antispam Module</title>
105105+ <para>
106106+ A Synapse module is also available to apply the same rulesets the
107107+ bot uses across an entire homeserver.
108108+ </para>
109109+ <para>
110110+ To use the Antispam Module, add
111111+ <literal>matrix-synapse-plugins.matrix-synapse-mjolnir-antispam</literal>
112112+ to the Synapse plugin list and enable the
113113+ <literal>mjolnir.Module</literal> module.
114114+ </para>
115115+ <programlisting>
104116{
105117 services.matrix-synapse = {
106118 plugins = with pkgs; [
···125137 # to already be joined to the room - Mjolnir will not automatically join
126138 # these rooms.
127139 ban_lists:
128128- - "!roomid:example.org"
140140+ - "!roomid:example.org"
129141 '';
130142 };
131143}
132144</programlisting>
133133- </section>
145145+ </section>
134146</chapter>