Skip to content

Commit

Permalink
Add config enable_activity_tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
Half-Shot committed Nov 18, 2021
1 parent 9c0a42d commit 38e10fa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions mautrix_telegram/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ def prepare_bridge(self) -> None:
self.add_startup_actions(self.resend_bridge_info())

# Explicitly not a startup_action, as startup_actions block startup
self.periodic_sync_task = self.loop.create_task(self._loop_active_puppet_metric())
if self.config['bridge.limits.enable_activity_tracking'] is not False:
self.periodic_sync_task = self.loop.create_task(self._loop_active_puppet_metric())


async def resend_bridge_info(self) -> None:
Expand All @@ -117,7 +118,8 @@ async def resend_bridge_info(self) -> None:
self.log.info("Finished re-sending bridge info state events")

def prepare_stop(self) -> None:
self.periodic_sync_task.cancel()
if self.periodic_sync_task:
self.periodic_sync_task.cancel()
for puppet in Puppet.by_custom_mxid.values():
puppet.stop()
self.shutdown_actions = (user.stop() for user in User.by_tgid.values())
Expand Down
1 change: 1 addition & 0 deletions mautrix_telegram/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ def do_update(self, helper: ConfigUpdateHelper) -> None:

copy("bridge.command_prefix")

copy("bridge.limits.enable_activity_tracking")
copy("bridge.limits.max_puppet_limit")
copy("bridge.limits.min_puppet_activity_days")
copy("bridge.limits.puppet_inactivity_days")
Expand Down
2 changes: 2 additions & 0 deletions mautrix_telegram/example-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,8 @@ bridge:

# Limit usage of the bridge
limits:
# Enable tracking of active puppets. Disable if this causes performance issues.
enable_activity_tracking: true
# The maximum number of bridge puppets that can be "active" before the limit is reached
max_puppet_limit: 0
# The minimum amount of days a puppet must be active for before they are considered "active".
Expand Down

0 comments on commit 38e10fa

Please sign in to comment.