async function assignAttendee()

in chime-sdk-components/backend-cdk/src/join/join.js [98:120]


async function assignAttendee(meetingInfo) {
    console.log("Assinging Attendee: ", JSON.stringify(meetingInfo, null, 3));
    
    if (meetingInfo.eventStatus.attendees === null || meetingInfo.eventStatus.attendees.Attendees.length === 0) {
        meetingInfo.eventStatus.attendees = await createAttendees(meetingInfo)
    }
    
    meetingInfo.participant.attendeeInfo = meetingInfo.eventStatus.attendees.Attendees.pop();
    if (meetingInfo.eventStatus.participants === undefined || meetingInfo.eventStatus.participants === null) {
        meetingInfo.participants = [meetingInfo.participant];
    } else {
        meetingInfo.eventStatus.participants.forEach((id, index) => {
            if (meetingInfo.eventStatus.participants[index].ParticipantID === meetingInfo.participant.ParticipantID) {
                meetingInfo.eventStatus.participants.splice(index, 1)
            }
        })
        meetingInfo.participants = meetingInfo.eventStatus.participants
        meetingInfo.participants.push(meetingInfo.participant);
    }
    meetingInfo.attendees = meetingInfo.eventStatus.attendees

    return meetingInfo;
}