in AmazonChimeSDK/AmazonChimeSDK/ingestion/IngestionEventConverter.swift [58:89]
func toIngestionRecord(dirtyMeetingEvents: [DirtyMeetingEventItem], ingestionConfiguration: IngestionConfiguration) -> IngestionRecord {
if dirtyMeetingEvents.isEmpty {
return IngestionRecord(metadata: [:], events: [])
}
// TODO: Group by meeting ID won't work since attendees can rejoin with different attendeeIDs
let dirtyMeetingEventsGrouped = Dictionary(grouping: dirtyMeetingEvents, by: { $0.data.getMeetingId() })
let eventType = ingestionConfiguration.clientConfiguration.tag
let ingestionEvents = dirtyMeetingEventsGrouped.compactMap { (group) -> IngestionEvent? in
if let sampleMeetingEventItem = group.value.first {
// TODO: Using first event as sample for retrieveing metadata won't always work, since attendees can rejoin with different attendeeIDs
let metadata = toIngestionMetadata(ingestionMeetingEvent: sampleMeetingEventItem.data,
clientConfig: ingestionConfiguration.clientConfiguration)
let payloads = group.value.map {
toIngestionPayload(meetingEventItemId: $0.id,
meetingEvent: $0.data,
dirtyMeetingEventTtl: $0.ttl)
}
return IngestionEvent(type: eventType,
metadata: metadata,
payloads: payloads)
}
return nil
}
let rootMeta = toIngestionMetadata(attributes: EventAttributeUtils.getCommonAttributes(ingestionConfiguration: ingestionConfiguration))
return IngestionRecord(metadata: rootMeta,
events: ingestionEvents)
}