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

399
Vistas
Cómo hacer un flujo en directus con la siguiente función

Tengo un gancho personalizado (codificado) que funciona como:

  • una colección se actualiza
  • ¿Es la colección "eventos"?
  • es uno de los campos actualizados uno de estos: time_show_start, time_show_end, ...
  • obtener todos los contactos de una colección que quieren recibir correos
  • envíe un correo a estos contactos con información sobre el evento (incluidos los tiempos antiguos y nuevos)

debería verse algo como esto, pero simplemente no puedo hacer que funcione ingrese la descripción de la imagen aquí

 module.exports = function registerHook({ action }, { services, exceptions }) { const { MailService, ItemsService } = services; const { ServiceUnavailableException, ForbiddenException } = exceptions; // Send mail to admin when event time is updated action('items.update', async ({ keys, collection, payload }, { schema, accountability }) => { if (collection !== 'events') return; if ( !payload.time_get_in && !payload.time_setup_start && !payload.time_setup_end && !payload.time_soundcheck_start && !payload.time_soundcheck_end && !payload.time_dinner && !payload.time_doors && !payload.time_show_start && !payload.time_show_end && !payload.time_curfew_live_music && !payload.time_curfew_guests ) { return; } const eventsService = new ItemsService('events', { accountability: accountability, schema: schema }); const contactsService = new ItemsService('contacts', { accountability: accountability, schema: schema }); const mailService = new MailService({ schema }); const contacts = await contactsService.readByQuery({ filter: { getsmailon_eventtimechange: { _eq: true } } }); contacts.forEach(async (contact) => { keys.forEach(async (el) => { // get event let event = null; try { event = await eventsService.readOne(el, { fields: ['*'] }); } catch (error) { console.error(error); throw new ServiceUnavailableException(error); } // send mail try { await mailService.send({ to: contact.email, subject: 'Zeit der Veranstaltung ' + event.name + ' geändert', text: 'Zeit der Veranstaltung <b>' + event.name + '</b> geändert', template: { name: 'event-time-update', data: { collection: collection, event: event, payload: payload, }, }, }); console.log('mail sent for event', event.id); } catch (error) { console.error(error); throw new ServiceUnavailableException(error); } }); }); return; }); };
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