1 // *************************************************************************
3 // * xCALLY Motion - The Omnichannel Contact Center *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved *
6 // *************************************************************************
8 // * Email: info@xcally.com *
9 // * Website: https://www.xcally.com *
11 // *************************************************************************
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold. *
17 // *************************************************************************
18 var _0x2ba1=['findAll','then','setDataValue','unreadMessages','length','emit','catch','hasOwnProperty','hook','exports','../../mysqldb','MailInteraction','setMaxListeners','save','update','remove','Users','map'];(function(_0x1fd363,_0x355a82){var _0x5059ad=function(_0x19aeaa){while(--_0x19aeaa){_0x1fd363['push'](_0x1fd363['shift']());}};_0x5059ad(++_0x355a82);}(_0x2ba1,0x64));var _0x12ba=function(_0x275cc0,_0x138402){_0x275cc0=_0x275cc0-0x0;var _0x3f53e7=_0x2ba1[_0x275cc0];return _0x3f53e7;};'use strict';var EventEmitter=require('events');var MailInteraction=require(_0x12ba('0x0'))['db'][_0x12ba('0x1')];var MailMessage=require(_0x12ba('0x0'))['db']['MailMessage'];var MailInteractionEvents=new EventEmitter();MailInteractionEvents[_0x12ba('0x2')](0x0);var events={'afterCreate':_0x12ba('0x3'),'afterUpdate':_0x12ba('0x4'),'afterDestroy':_0x12ba('0x5')};function emitEvent(_0x4907dd){return function(_0xdf01fd,_0x82570d,_0x1a9823){_0xdf01fd['getUsers']({'attributes':['id'],'raw':!![]})['then'](function(_0x59adea){_0xdf01fd['setDataValue'](_0x12ba('0x6'),_0x59adea[_0x12ba('0x7')](function(_0x500e18){return{'id':_0x500e18['id']};}));return MailMessage[_0x12ba('0x8')]({'where':{'MailInteractionId':_0xdf01fd['id'],'direction':'in','read':![]},'raw':!![]});})[_0x12ba('0x9')](function(_0x1a2f39){_0xdf01fd[_0x12ba('0xa')](_0x12ba('0xb'),_0x1a2f39[_0x12ba('0xc')]);MailInteractionEvents['emit'](_0x4907dd+':'+_0xdf01fd['id'],_0xdf01fd);MailInteractionEvents[_0x12ba('0xd')](_0x4907dd,_0xdf01fd);_0x1a9823(null);})[_0x12ba('0xe')](_0x1a9823(null));};}for(var e in events){if(events[_0x12ba('0xf')](e)){var event=events[e];MailInteraction[_0x12ba('0x10')](e,emitEvent(event));}}module[_0x12ba('0x11')]=MailInteractionEvents;