@@ -191,6 +191,7 @@ type AndroidNotification struct {
191
191
DefaultLightSettings bool `json:"default_light_settings,omitempty"`
192
192
Visibility AndroidNotificationVisibility `json:"-"`
193
193
NotificationCount * int `json:"notification_count,omitempty"`
194
+ Proxy AndroidNotificationProxy `json:"-"`
194
195
}
195
196
196
197
// MarshalJSON marshals an AndroidNotification into JSON (for internal use only).
@@ -217,6 +218,16 @@ func (a *AndroidNotification) MarshalJSON() ([]byte, error) {
217
218
visibility , _ = visibilities [a .Visibility ]
218
219
}
219
220
221
+ var proxy string
222
+ if a .Proxy != proxyUnspecified {
223
+ proxies := map [AndroidNotificationProxy ]string {
224
+ ProxyAllow : "ALLOW" ,
225
+ ProxyDeny : "DENY" ,
226
+ ProxyIfPriorityLowered : "IF_PRIORITY_LOWERED" ,
227
+ }
228
+ proxy , _ = proxies [a .Proxy ]
229
+ }
230
+
220
231
var timestamp string
221
232
if a .EventTimestamp != nil {
222
233
timestamp = a .EventTimestamp .UTC ().Format (rfc3339Zulu )
@@ -232,12 +243,14 @@ func (a *AndroidNotification) MarshalJSON() ([]byte, error) {
232
243
EventTimestamp string `json:"event_time,omitempty"`
233
244
Priority string `json:"notification_priority,omitempty"`
234
245
Visibility string `json:"visibility,omitempty"`
246
+ Proxy string `json:"proxy,omitempty"`
235
247
VibrateTimings []string `json:"vibrate_timings,omitempty"`
236
248
* androidInternal
237
249
}{
238
250
EventTimestamp : timestamp ,
239
251
Priority : priority ,
240
252
Visibility : visibility ,
253
+ Proxy : proxy ,
241
254
VibrateTimings : vibTimings ,
242
255
androidInternal : (* androidInternal )(a ),
243
256
}
@@ -251,6 +264,7 @@ func (a *AndroidNotification) UnmarshalJSON(b []byte) error {
251
264
EventTimestamp string `json:"event_time,omitempty"`
252
265
Priority string `json:"notification_priority,omitempty"`
253
266
Visibility string `json:"visibility,omitempty"`
267
+ Proxy string `json:"proxy,omitempty"`
254
268
VibrateTimings []string `json:"vibrate_timings,omitempty"`
255
269
* androidInternal
256
270
}{
@@ -288,6 +302,19 @@ func (a *AndroidNotification) UnmarshalJSON(b []byte) error {
288
302
}
289
303
}
290
304
305
+ if temp .Proxy != "" {
306
+ proxies := map [string ]AndroidNotificationProxy {
307
+ "ALLOW" : ProxyAllow ,
308
+ "DENY" : ProxyDeny ,
309
+ "IF_PRIORITY_LOWERED" : ProxyIfPriorityLowered ,
310
+ }
311
+ if prox , ok := proxies [temp .Proxy ]; ok {
312
+ a .Proxy = prox
313
+ } else {
314
+ return fmt .Errorf ("unknown proxy value: %q" , temp .Proxy )
315
+ }
316
+ }
317
+
291
318
if temp .EventTimestamp != "" {
292
319
ts , err := time .Parse (rfc3339Zulu , temp .EventTimestamp )
293
320
if err != nil {
@@ -356,6 +383,23 @@ const (
356
383
VisibilitySecret
357
384
)
358
385
386
+ // AndroidNotificationProxy to control when a notification may be proxied.
387
+ type AndroidNotificationProxy int
388
+
389
+ const (
390
+ proxyUnspecified AndroidNotificationProxy = iota
391
+
392
+ // ProxyAllow tries to proxy this notification.
393
+ ProxyAllow
394
+
395
+ // ProxyDeny does not proxy this notification.
396
+ ProxyDeny
397
+
398
+ // ProxyIfPriorityLowered only tries to proxy this notification if its AndroidConfig's Priority was
399
+ // lowered from high to normal on the device.
400
+ ProxyIfPriorityLowered
401
+ )
402
+
359
403
// LightSettings to control notification LED.
360
404
type LightSettings struct {
361
405
Color string
0 commit comments