Auto deleting accounts after n-days since last login or activity

Is there a way to automaticly delete accounts with no activity after n days?

We have a requirement to audit all user access to all our applicaitons. usually this isn’t a big deal when syncing with ldap, but rocket chat does not remove accounts when they are removed from ldap. This requires manual audit, and is a pain! If rocket chat ldap sync will not remove accounts, the next best thing would be to remove accounts based on non activity.
Thanks