bnjbvr/trinity

[linkify] Enabled config for a rule persists after it is deleted

ahal opened this issue · 1 comments

ahal commented

If you enable a rule in a room, then delete that rule, it will still exist in the key store for that room. This is mostly harmless other than storing unnecessary data as the match algorithm iterates over only the rules that exist. But would be good to clean these up to avoid confusion (especially if we add a command to list enabled rules).

One consideration is what to do when deleting a rule that is enabled in other rooms? Should we:

  1. Delete it anyway and automatically remove the enabled configs?
  2. Prevent deleting it until it has been disabled everywhere?

The former might lead to admins accidentally deleting rules they didn't realize were still in use. The latter might make it really annoying to delete. Maybe there could be a --force option or something as a compromise.

It also has the benefit that when "iterating" over regular expressions, it's one fewer step in the disable-delete-recreate process. But that can likely be solved in a better way, by having an "update" admin command in linkify.

I kind of like 2, with the workaround of having --force which will ignore the enabled rules. In both cases, we need a mapping from "which rules are enabled in which rooms", so maybe a third entry in the KV store with a constant key, that contains a mapping of rule name --> list of rooms where that rule is enabled. Or a per-rule mapping, in rule:RULE_NAME --> list of rooms where that rule is enabled. Or equivalently, extend the value in the existing rule mapping (but that's a data migration).