@@ -17,7 +17,6 @@ use crate::{
1717 notify:: NotifierConfig ,
1818 platform:: * ,
1919 reporter:: { ConfigReporterRaw , ReporterParams } ,
20- serde_impl_default_for,
2120 source:: SourceConfig ,
2221} ;
2322
@@ -191,17 +190,21 @@ pub struct SubscriptionRef<'a> {
191190
192191// Should be always used with `#[serde(flatten)]`
193192#[ derive( Clone , Debug , PartialEq , Deserialize ) ]
194- pub struct NotifierBase {
193+ pub struct NotifierBase < O = ( ) > {
195194 #[ serde( default ) ]
196195 pub switch : NotificationSwitch ,
197196 #[ serde( default ) ]
198- pub option : NotificationOption ,
197+ pub option : NotificationOption < O > ,
199198}
200199
201- serde_impl_default_for ! ( NotifierBase ) ;
200+ impl < ' a , O : Default + Deserialize < ' a > > Default for NotifierBase < O > {
201+ fn default ( ) -> Self {
202+ helper:: serde_default ( )
203+ }
204+ }
202205
203- impl Overridable for NotifierBase {
204- type Override = NotifierBaseOverride ;
206+ impl < ' a , O : Deserialize < ' a > + Overridable > Overridable for NotifierBase < O > {
207+ type Override = NotifierBaseOverride < O :: Override > ;
205208
206209 fn override_into ( self , new : Self :: Override ) -> Self
207210 where
@@ -222,9 +225,9 @@ impl Overridable for NotifierBase {
222225
223226// Should be always used with `#[serde(flatten)]`
224227#[ derive( Clone , Debug , PartialEq , Deserialize ) ]
225- pub struct NotifierBaseOverride {
228+ pub struct NotifierBaseOverride < O = ( ) > {
226229 switch : Option < NotificationSwitchOverride > ,
227- option : Option < NotificationOptionOverride > ,
230+ option : Option < NotificationOptionOverride < O > > ,
228231}
229232
230233#[ derive( Clone , Debug , PartialEq , Deserialize ) ]
@@ -243,7 +246,11 @@ pub struct NotificationSwitch {
243246 pub document : bool ,
244247}
245248
246- serde_impl_default_for ! ( NotificationSwitch ) ;
249+ impl Default for NotificationSwitch {
250+ fn default ( ) -> Self {
251+ helper:: serde_default ( )
252+ }
253+ }
247254
248255impl Overridable for NotificationSwitch {
249256 type Override = NotificationSwitchOverride ;
@@ -274,37 +281,41 @@ pub struct NotificationSwitchOverride {
274281}
275282
276283#[ derive( Clone , Debug , PartialEq , Deserialize ) ]
277- pub struct NotificationOption {
284+ pub struct NotificationOption < O > {
278285 #[ serde( default = "helper::refl_bool::<false>" ) ]
279286 pub author_name : bool ,
280-
281- // TODO: For temporary use on QQ platform, due to demand from a particular user. We eventually
282- // want to support custom text via pattern templates (similar to spdlog-rs, but more generic).
283- // And because they are temporary, we do not currently support their overriding.
284- pub __live_text : Option < String > ,
285- pub __post_text : Option < String > ,
287+ #[ serde( default , flatten) ]
288+ pub ext : O ,
286289}
287290
288- serde_impl_default_for ! ( NotificationOption ) ;
291+ impl < ' a , O : Default + Deserialize < ' a > > Default for NotificationOption < O > {
292+ fn default ( ) -> Self {
293+ helper:: serde_default ( )
294+ }
295+ }
289296
290- impl Overridable for NotificationOption {
291- type Override = NotificationOptionOverride ;
297+ impl < ' a , O : Deserialize < ' a > + Overridable > Overridable for NotificationOption < O > {
298+ type Override = NotificationOptionOverride < O :: Override > ;
292299
293300 fn override_into ( self , new : Self :: Override ) -> Self
294301 where
295302 Self : Sized ,
296303 {
297304 Self {
298305 author_name : new. author_name . unwrap_or ( self . author_name ) ,
299- __live_text : self . __live_text ,
300- __post_text : self . __post_text ,
306+ ext : match new. ext {
307+ Some ( ext) => self . ext . override_into ( ext) ,
308+ None => self . ext ,
309+ } ,
301310 }
302311 }
303312}
304313
305314#[ derive( Clone , Debug , PartialEq , Deserialize ) ]
306- pub struct NotificationOptionOverride {
315+ pub struct NotificationOptionOverride < O > {
307316 pub author_name : Option < bool > ,
317+ #[ serde( flatten) ]
318+ pub ext : Option < O > ,
308319}
309320
310321#[ derive( Debug , PartialEq , Deserialize ) ]
@@ -470,8 +481,7 @@ notify = ["meow", "woof", { ref = "woof", id = 123 }]
470481 } ,
471482 option: NotificationOption {
472483 author_name: false ,
473- __live_text: None ,
474- __post_text: None ,
484+ ext: ( )
475485 }
476486 } ,
477487 chat: telegram:: ConfigChat :: Id ( 5678 ) ,
0 commit comments