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 _0x4fcf=['emit','events','../../mysqldb','MailInteraction','MailMessage','setMaxListeners','save','update','remove','getUsers','then','Users','map','findAll','length'];(function(_0x19e35c,_0x29cd1e){var _0x3e1fe8=function(_0x17258b){while(--_0x17258b){_0x19e35c['push'](_0x19e35c['shift']());}};_0x3e1fe8(++_0x29cd1e);}(_0x4fcf,0x1d2));var _0xf4fc=function(_0x416b18,_0x2675b5){_0x416b18=_0x416b18-0x0;var _0x575f4e=_0x4fcf[_0x416b18];return _0x575f4e;};'use strict';var EventEmitter=require(_0xf4fc('0x0'));var MailInteraction=require(_0xf4fc('0x1'))['db'][_0xf4fc('0x2')];var MailMessage=require('../../mysqldb')['db'][_0xf4fc('0x3')];var MailInteractionEvents=new EventEmitter();MailInteractionEvents[_0xf4fc('0x4')](0x0);var events={'afterCreate':_0xf4fc('0x5'),'afterUpdate':_0xf4fc('0x6'),'afterDestroy':_0xf4fc('0x7')};function emitEvent(_0x5c69d7){return function(_0x1d020c,_0x3ae6c2,_0x112fc1){_0x1d020c[_0xf4fc('0x8')]({'attributes':['id'],'raw':!![]})[_0xf4fc('0x9')](function(_0x292cde){_0x1d020c['setDataValue'](_0xf4fc('0xa'),_0x292cde[_0xf4fc('0xb')](function(_0x57b088){return{'id':_0x57b088['id']};}));return MailMessage[_0xf4fc('0xc')]({'where':{'MailInteractionId':_0x1d020c['id'],'direction':'in','read':![]},'raw':!![]});})[_0xf4fc('0x9')](function(_0x35f66c){_0x1d020c['setDataValue']('unreadMessages',_0x35f66c[_0xf4fc('0xd')]);MailInteractionEvents[_0xf4fc('0xe')](_0x5c69d7+':'+_0x1d020c['id'],_0x1d020c);MailInteractionEvents[_0xf4fc('0xe')](_0x5c69d7,_0x1d020c);_0x112fc1(null);})['catch'](_0x112fc1(null));};}for(var e in events){if(events['hasOwnProperty'](e)){var event=events[e];MailInteraction['hook'](e,emitEvent(event));}}module['exports']=MailInteractionEvents;