in models/v3/msgs/msgs.go [220:264]
func (n Notifications) toEvent() ([]byte, envelope.Event, error) {
dataJSON, inline, err := n.inline()
if err != nil {
return dataJSON, envelope.Event{}, err
}
meta, err := newEventMeta(n.Data)
if err != nil {
return dataJSON, envelope.Event{}, fmt.Errorf("problem creating an EventMeta: %w", err)
}
if len(n.Data) > math.MaxUint16 {
return dataJSON, envelope.Event{}, fmt.Errorf("too many resources to send in a single event: %d", len(n.Data))
}
n.AdditionalBatchProperties.BatchSize = uint16(len(n.Data))
n.AdditionalBatchProperties.SDKVersion = version.SDK.AsARNFormat()
if inline {
return dataJSON, envelope.Event{
EventMeta: meta,
Data: types.Data{
Data: dataJSON, // This serializes into the "Resources" field.
FrontdoorLocation: n.FrontdoorLocation,
AdditionalBatchProperties: n.AdditionalBatchProperties,
ResourcesContainer: types.RCInline,
ResourceLocation: n.ResourceLocation,
PublisherInfo: n.PublisherInfo,
Resources: n.Data, // This doesn't serialize into JSON, only the "Data" field does, which actually replaces this field.
},
}, nil
}
return dataJSON, envelope.Event{
EventMeta: meta,
Data: types.Data{
FrontdoorLocation: n.FrontdoorLocation,
AdditionalBatchProperties: n.AdditionalBatchProperties,
ResourcesContainer: types.RCBlob,
ResourceLocation: n.ResourceLocation,
PublisherInfo: n.PublisherInfo,
Resources: n.Data, // This doesn't serialize into JSON, only the "Data" field does, which actually replaces this field.
},
}, nil
}