Add mau_appservice_trial_days config (#12619)

* Add mau_appservice_trial_days

* Add a test

* Tweaks

* changelog

* Ensure we sync after the delay

* Fix types

* Add config statement

* Fix test

* Reinstate logging that got removed

* Fix feature name
This commit is contained in:
Will Hunt 2022-05-04 19:33:26 +01:00 committed by GitHub
parent 7fbf42499d
commit 2d74a8c178
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 110 additions and 2 deletions

View file

@ -215,7 +215,8 @@ class RegistrationWorkerStore(CacheInvalidationWorkerStore):
async def is_trial_user(self, user_id: str) -> bool:
"""Checks if user is in the "trial" period, i.e. within the first
N days of registration defined by `mau_trial_days` config
N days of registration defined by `mau_trial_days` config or the
`mau_appservice_trial_days` config.
Args:
user_id: The user to check for trial status.
@ -226,7 +227,10 @@ class RegistrationWorkerStore(CacheInvalidationWorkerStore):
return False
now = self._clock.time_msec()
trial_duration_ms = self.config.server.mau_trial_days * 24 * 60 * 60 * 1000
days = self.config.server.mau_appservice_trial_days.get(
info["appservice_id"], self.config.server.mau_trial_days
)
trial_duration_ms = days * 24 * 60 * 60 * 1000
is_trial = (now - info["creation_ts"] * 1000) < trial_duration_ms
return is_trial