File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -120,10 +120,26 @@ func (m *Message) Parse() error {
120
120
return fmt .Errorf (EUnsuccessfulReply , string (m .Body )[5 :])
121
121
}
122
122
case "text/event-json" :
123
- if err := json .Unmarshal (m .Body , & m .Headers ); err != nil {
123
+ // OK, what is missing here is a way to interpret other JSON types - it expects string only (understandably
124
+ // because the FS events are generally "string: string") - extract into empty interface and migrate only strings.
125
+ // i.e. Event CHANNEL_EXECUTE_COMPLETE - "variable_DP_MATCH":["a=rtpmap:101 telephone-event/8000","101"]
126
+ var decoded map [string ]interface {}
127
+
128
+ if err := json .Unmarshal (m .Body , & decoded ); err != nil {
124
129
return err
125
130
}
126
131
132
+ // Copy back in:
133
+ for k , v := range decoded {
134
+ switch v .(type ) {
135
+ case string :
136
+ m .Headers [k ] = v .(string )
137
+ default :
138
+ //delete(m.Headers, k)
139
+ Warning ("Removed non-string property (%s)" , k )
140
+ }
141
+ }
142
+
127
143
if v , _ := m .Headers ["_body" ]; v != "" {
128
144
m .Body = []byte (v )
129
145
delete (m .Headers , "_body" )
You can’t perform that action at this time.
0 commit comments