Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

158
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda