Make automatic full Matrix state syncs optional

This commit is contained in:
Tulir Asokan
2019-01-07 19:58:16 +02:00
parent a090d6de32
commit 01426308c5
3 changed files with 8 additions and 2 deletions
+3
View File
@@ -107,6 +107,9 @@ bridge:
# If no channel admins have logged into the bridge, the bridge won't be able to sync the member
# list regardless of this setting.
sync_channel_members: true
# Whether or not to automatically sync the Matrix room state (mostly unpuppeted displaynames)
# at startup and when creating a bridge.
sync_matrix_state: true
# The maximum number of simultaneous Telegram deletions to handle.
# A large number of simultaneous redactions could put strain on your homeserver.
max_telegram_delete: 10
+1
View File
@@ -203,6 +203,7 @@ class Config(DictWithRecursion):
copy("bridge.bot_messages_as_notices")
copy("bridge.max_initial_member_sync")
copy("bridge.sync_channel_members")
copy("bridge.sync_matrix_state")
copy("bridge.max_telegram_delete")
copy("bridge.allow_matrix_login")
copy("bridge.inline_images")
+4 -2
View File
@@ -101,6 +101,7 @@ class Portal:
public_portals = False # type: bool
max_initial_member_sync = -1 # type: int
sync_channel_members = True # type: bool
sync_matrix_state = True # type: bool
dedup_pre_db_check = False # type: bool
dedup_cache_queue_length = 20 # type: int
@@ -328,7 +329,8 @@ class Portal:
puppet = p.Puppet.get(self.tgid)
await puppet.update_info(user, entity)
await puppet.intent.join_room(self.mxid)
await self.sync_matrix_members()
if self.sync_matrix_state:
await self.sync_matrix_members()
async def create_matrix_room(self, user: 'AbstractUser', entity: TypeChat = None,
invites: InviteList = None, update_if_exists: bool = True,
@@ -786,7 +788,6 @@ class Portal:
async def sync_matrix_members(self) -> None:
resp = await self.main_intent.get_room_joined_memberships(self.mxid)
members = resp["joined"]
print(members)
for mxid, info in members.items():
member = {
"membership": "join",
@@ -1955,6 +1956,7 @@ def init(context: Context) -> None:
Portal.az, Portal.db, config, Portal.loop, Portal.bot = context.core
Portal.max_initial_member_sync = config["bridge.max_initial_member_sync"]
Portal.sync_channel_members = config["bridge.sync_channel_members"]
Portal.sync_matrix_state = config["bridge.sync_matrix_state"]
Portal.public_portals = config["bridge.public_portals"]
Portal.filter_mode = config["bridge.filter.mode"]
Portal.filter_list = config["bridge.filter.list"]