Skip to content

Commit 7f353ab

Browse files
committed
Generate AS registrations with bot sync workaround
Looks like synapse isn't going to be fixed soon (matrix-org/synapse#5758), so this changes all registrations to be generated using the workaround: the sender_localpart is set to a random string and the actual AS bot is added as another namespace.
1 parent 8aabfd2 commit 7f353ab

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

mautrix/bridge/config.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from abc import ABC, abstractmethod
88
import random
99
import string
10+
import re
1011

1112
from mautrix.util.config import (BaseFileConfig, ConfigUpdateHelper, BaseValidatableConfig,
1213
ForbiddenDefault, ForbiddenKey, yaml)
@@ -87,12 +88,18 @@ def generate_registration(self) -> None:
8788
self["appservice.as_token"] = self._new_token()
8889
self["appservice.hs_token"] = self._new_token()
8990

91+
namespaces = self.namespaces
92+
namespaces.setdefault("users", []).append({
93+
"exclusive": True,
94+
"regex": re.escape(self["appservice.bot_username"]),
95+
})
96+
9097
self._registration = {
9198
"id": self["appservice.id"],
9299
"as_token": self["appservice.as_token"],
93100
"hs_token": self["appservice.hs_token"],
94-
"namespaces": self.namespaces,
101+
"namespaces": namespaces,
95102
"url": self["appservice.address"],
96-
"sender_localpart": self["appservice.bot_username"],
103+
"sender_localpart": self._new_token(),
97104
"rate_limited": False
98105
}

0 commit comments

Comments
 (0)