const {fetchCommentsFromServiceNow } = require('../services/servicenowService'); const { syncCommentsGlpitoSN, syncCommentsSNtoGlpi } = require('../services/glpiCommentService'); const TicketSyncModel = require('../models/ticketSyncModel'); const processCommentsController = async () => { // Usa getTicketsToMonitor para incluir tickets 'synced' e 'solved'. const ticketsToMonitor = await TicketSyncModel.getTicketsToMonitor(); for (const ticket of ticketsToMonitor){ const comments = await fetchCommentsFromServiceNow(ticket); if(comments.length != 0){await syncCommentsSNtoGlpi(comments, ticket);} await syncCommentsGlpitoSN(ticket); } } module.exports = { processCommentsController }