Store pushrules in model with (kind, rule_id) keys

Two rules of different kinds can have the same rule ID
This commit is contained in:
miruka
2020-11-01 01:10:49 -04:00
parent d5bcaca874
commit 99c5346dba
6 changed files with 50 additions and 52 deletions

View File

@@ -97,17 +97,18 @@ class PushRuleKind(AutoStrEnum):
class PushRule(ModelItem):
"""A push rule configured for one of our account."""
id: str = field()
kind: PushRuleKind = field()
order: int = field()
default: bool = field()
enabled: bool = True
pattern: str = ""
notify: bool = False
highlight: bool = False
bubble: bool = False
sound: bool = False
urgency_hint: bool = False
id: Tuple[str, str] = field() # (kind.value, rule_id)
kind: PushRuleKind = field()
rule_id: str = field()
order: int = field()
default: bool = field()
enabled: bool = True
pattern: str = ""
notify: bool = False
highlight: bool = False
bubble: bool = False
sound: bool = False
urgency_hint: bool = False
def __lt__(self, other: "PushRule") -> bool:
"""Sort by `kind`, then `order`."""