2025-10-13 06:06:52 -03:00
|
|
|
const {fetchCommentsFromServiceNow } = require('../services/servicenowService');
|
2025-10-17 16:58:14 -03:00
|
|
|
const { syncCommentsGlpitoSN, syncCommentsSNtoGlpi } = require('../services/glpiCommentService');
|
|
|
|
|
const TicketSyncModel = require('../models/ticketSyncModel');
|
2025-10-13 06:06:52 -03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
const processCommentsController = async () => {
|
|
|
|
|
|
2025-10-17 16:58:14 -03:00
|
|
|
const ticketsSynced = await TicketSyncModel.getTicketsSynced();
|
|
|
|
|
|
|
|
|
|
for (ticket of ticketsSynced){
|
|
|
|
|
const comments = await fetchCommentsFromServiceNow(ticket);
|
|
|
|
|
if(comments.length > 0){await syncCommentsSNtoGlpi(comments, ticket);}
|
|
|
|
|
await syncCommentsGlpitoSN(ticket);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2025-10-13 06:06:52 -03:00
|
|
|
module.exports = {
|
|
|
|
|
processCommentsController
|
|
|
|
|
}
|