@@ -20,8 +20,11 @@ class ImageAttachMethod(Enum):
20
20
CLICK = "click"
21
21
22
22
@staticmethod
23
- def all_values () -> set :
24
- return {e .value for e in ImageAttachMethod }
23
+ def from_str (method : str ) -> "ImageAttachMethod" :
24
+ return {
25
+ ImageAttachMethod .ATTACH .value .lower (): ImageAttachMethod .ATTACH ,
26
+ ImageAttachMethod .CLICK .value .lower (): ImageAttachMethod .CLICK ,
27
+ }[method .lower ()]
25
28
26
29
27
30
class NtfyPriority (Enum ):
@@ -41,9 +44,25 @@ class NtfyPriority(Enum):
41
44
def all_values () -> set :
42
45
return {e .value for e in NtfyPriority }
43
46
47
+ @staticmethod
48
+ def from_str (pri : str ) -> "NtfyPriority" :
49
+ return {
50
+ NtfyPriority .N_1 .value .lower (): NtfyPriority .N_1 ,
51
+ NtfyPriority .MIN .value .lower (): NtfyPriority .MIN ,
52
+ NtfyPriority .N_2 .value .lower (): NtfyPriority .N_2 ,
53
+ NtfyPriority .LOW .value .lower (): NtfyPriority .LOW ,
54
+ NtfyPriority .N_3 .value .lower (): NtfyPriority .N_3 ,
55
+ NtfyPriority .DEFAULT .value .lower (): NtfyPriority .DEFAULT ,
56
+ NtfyPriority .N_4 .value .lower (): NtfyPriority .N_4 ,
57
+ NtfyPriority .HIGH .value .lower (): NtfyPriority .HIGH ,
58
+ NtfyPriority .N_5 .value .lower (): NtfyPriority .N_5 ,
59
+ NtfyPriority .MAX .value .lower (): NtfyPriority .MAX ,
60
+ NtfyPriority .URGENT .value .lower (): NtfyPriority .URGENT ,
61
+ }[pri .lower ()]
62
+
44
63
45
- NOTIF_PRIORITY_UNMUTED : Final = NtfyPriority .DEFAULT
46
- NOTIF_PRIORITY_MUTED : Final = NtfyPriority .MIN
64
+ NOTIF_PRIORITY_UNMUTED : Final = NtfyPriority .DEFAULT . value
65
+ NOTIF_PRIORITY_MUTED : Final = NtfyPriority .MIN . value
47
66
48
67
49
68
@dataclasses .dataclass (frozen = True )
@@ -73,7 +92,7 @@ class NtfyConfig:
73
92
token : Optional [str ] = None
74
93
debounce_threshold_s : float = 60.0
75
94
default_priority : NtfyPriority = NtfyPriority .DEFAULT
76
- priorities : Dict [str , str ] = dataclasses .field (default_factory = lambda : {})
95
+ priorities : Dict [str , NtfyPriority ] = dataclasses .field (default_factory = lambda : {})
77
96
req_timeout_s : float = 10.0
78
97
image_method : Optional [ImageAttachMethod ] = None
79
98
images_cc_dir : Optional [str ] = None
@@ -193,7 +212,7 @@ def _prep_ntfy_headers(self, n: Notification) -> Dict[str, str]:
193
212
headers ["Priority" ] = self ._config .priorities .get (
194
213
n .classification ,
195
214
self ._config .default_priority ,
196
- )
215
+ ). value
197
216
elif isinstance (n , FeedbackNotification ):
198
217
if n .type == FeedbackType .MUTED :
199
218
headers ["Priority" ] = NOTIF_PRIORITY_MUTED
0 commit comments