Skip to content

Commit 6374900

Browse files
committed
fix AndroidNotificationProxy unmarshalling problem
1 parent 329c503 commit 6374900

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

messaging/messaging.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ func (a *AndroidNotification) UnmarshalJSON(b []byte) error {
264264
EventTimestamp string `json:"event_time,omitempty"`
265265
Priority string `json:"notification_priority,omitempty"`
266266
Visibility string `json:"visibility,omitempty"`
267+
Proxy string `json:"proxy,omitempty"`
267268
VibrateTimings []string `json:"vibrate_timings,omitempty"`
268269
*androidInternal
269270
}{
@@ -301,6 +302,19 @@ func (a *AndroidNotification) UnmarshalJSON(b []byte) error {
301302
}
302303
}
303304

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+
304318
if temp.EventTimestamp != "" {
305319
ts, err := time.Parse(rfc3339Zulu, temp.EventTimestamp)
306320
if err != nil {

0 commit comments

Comments
 (0)