Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

161
Visualizações
Filter attendees in Google Calendar Api

I use google calendar api to import events into Google Sheet. I'm trying to omit event.creator from representation if he isn't a participant (for example assistant created an event) and can't find the solution.

I'm new to programming, so I just suppose I need to add a filter or write a new function.

Here is the snippet:

    function transformCalendarEvents(rawCalendarEvents) {
  /**
   *
   * @param {Calendar_v3.Calendar.V3.Schema.Event} event
   * @return {EventAttendee[]}
   */
  function getEventAttendees(event){
    /**
     *
     * @param {Object} event
     * @return {EventAttendee}
     */    
    function createEventAttendee(srcAttendee) {
      return {
        name: srcAttendee.displayName,
        email: srcAttendee.email,
        responseStatus: srcAttendee.responseStatus,
        organizer: srcAttendee.organizer || false,
        optional: srcAttendee.optional || false,
      }
    }

    let attendees = event.attendees || []

    if (event.creator && !attendees.map(a => a.email).includes(event.creator.email)) {
      attendees.push({
        ...event.creator,
        organizer: true,
        optional: false,
        responseStatus: event.creator.responseStatus || 'declined',
      })
    }

    if (event.organizer && !attendees.map(a => a.email).includes(event.organizer.email)) {
      attendees.push({
        ...event.organizer,
        organizer: true,
        optional: false,
        responseStatus: event.creator.responseStatus || 'declined',
      })
    }

    attendees = attendees.filter(
      atd => atd.email.indexOf('@resource.calendar.google.com') == -1
    ).sort(
      (a1, a2) => +!!a2.organizer - +!!a1.organizer
    )

    return attendees.map(createEventAttendee) 
  }

Any help would be appreciated

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda