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 _0x5fe5=['save','update','getUsers','map','findAll','then','unreadMessages','length','emit','catch','hasOwnProperty','hook','exports','../../mysqldb','MailInteraction','MailMessage'];(function(_0x5de8fa,_0x4665af){var _0x136868=function(_0xf16f59){while(--_0xf16f59){_0x5de8fa['push'](_0x5de8fa['shift']());}};_0x136868(++_0x4665af);}(_0x5fe5,0x9d));var _0x55fe=function(_0x55de53,_0x5da3e7){_0x55de53=_0x55de53-0x0;var _0x362fbe=_0x5fe5[_0x55de53];return _0x362fbe;};'use strict';var EventEmitter=require('events');var MailInteraction=require(_0x55fe('0x0'))['db'][_0x55fe('0x1')];var MailMessage=require(_0x55fe('0x0'))['db'][_0x55fe('0x2')];var MailInteractionEvents=new EventEmitter();MailInteractionEvents['setMaxListeners'](0x0);var events={'afterCreate':_0x55fe('0x3'),'afterUpdate':_0x55fe('0x4'),'afterDestroy':'remove'};function emitEvent(_0x530679){return function(_0x5b32b4,_0x43aa2b,_0x1ccbbc){_0x5b32b4[_0x55fe('0x5')]({'attributes':['id'],'raw':!![]})['then'](function(_0x4472bd){_0x5b32b4['setDataValue']('Users',_0x4472bd[_0x55fe('0x6')](function(_0x3c5b39){return{'id':_0x3c5b39['id']};}));return MailMessage[_0x55fe('0x7')]({'where':{'MailInteractionId':_0x5b32b4['id'],'direction':'in','read':![]},'raw':!![]});})[_0x55fe('0x8')](function(_0x3f27e2){_0x5b32b4['setDataValue'](_0x55fe('0x9'),_0x3f27e2[_0x55fe('0xa')]);MailInteractionEvents[_0x55fe('0xb')](_0x530679+':'+_0x5b32b4['id'],_0x5b32b4);MailInteractionEvents['emit'](_0x530679,_0x5b32b4);_0x1ccbbc(null);})[_0x55fe('0xc')](_0x1ccbbc(null));};}for(var e in events){if(events[_0x55fe('0xd')](e)){var event=events[e];MailInteraction[_0x55fe('0xe')](e,emitEvent(event));}}module[_0x55fe('0xf')]=MailInteractionEvents;