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 _0x8bf1=['../../mysqldb','MailInteraction','MailMessage','setMaxListeners','save','update','remove','getUsers','then','Users','map','findAll','unreadMessages','length','emit','catch','hook','events'];(function(_0x334599,_0x4b1cfa){var _0x4cdff2=function(_0x297be7){while(--_0x297be7){_0x334599['push'](_0x334599['shift']());}};_0x4cdff2(++_0x4b1cfa);}(_0x8bf1,0x1e5));var _0x18bf=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x8bf1[_0x3dd15e];return _0x231fd0;};'use strict';var EventEmitter=require(_0x18bf('0x0'));var MailInteraction=require(_0x18bf('0x1'))['db'][_0x18bf('0x2')];var MailMessage=require(_0x18bf('0x1'))['db'][_0x18bf('0x3')];var MailInteractionEvents=new EventEmitter();MailInteractionEvents[_0x18bf('0x4')](0x0);var events={'afterCreate':_0x18bf('0x5'),'afterUpdate':_0x18bf('0x6'),'afterDestroy':_0x18bf('0x7')};function emitEvent(_0x4b467e){return function(_0x91d506,_0x5a6a35,_0x59d432){_0x91d506[_0x18bf('0x8')]({'attributes':['id'],'raw':!![]})[_0x18bf('0x9')](function(_0x298f08){_0x91d506['setDataValue'](_0x18bf('0xa'),_0x298f08[_0x18bf('0xb')](function(_0x42d92e){return{'id':_0x42d92e['id']};}));return MailMessage[_0x18bf('0xc')]({'where':{'MailInteractionId':_0x91d506['id'],'direction':'in','read':![]},'raw':!![]});})[_0x18bf('0x9')](function(_0x565c00){_0x91d506['setDataValue'](_0x18bf('0xd'),_0x565c00[_0x18bf('0xe')]);MailInteractionEvents[_0x18bf('0xf')](_0x4b467e+':'+_0x91d506['id'],_0x91d506);MailInteractionEvents[_0x18bf('0xf')](_0x4b467e,_0x91d506);_0x59d432(null);})[_0x18bf('0x10')](_0x59d432(null));};}for(var e in events){if(events['hasOwnProperty'](e)){var event=events[e];MailInteraction[_0x18bf('0x11')](e,emitEvent(event));}}module['exports']=MailInteractionEvents;