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 _0xf604=['hook','events','../../mysqldb','ChatInteraction','ChatMessage','save','update','getUsers','then','setDataValue','Users','map','findAll','unreadMessages','length','emit','catch'];(function(_0x689fec,_0x1f0e16){var _0x1ddefe=function(_0x5f2e8f){while(--_0x5f2e8f){_0x689fec['push'](_0x689fec['shift']());}};_0x1ddefe(++_0x1f0e16);}(_0xf604,0x122));var _0x4f60=function(_0x5e6aad,_0x3cdddd){_0x5e6aad=_0x5e6aad-0x0;var _0x55deab=_0xf604[_0x5e6aad];return _0x55deab;};'use strict';var EventEmitter=require(_0x4f60('0x0'));var ChatInteraction=require(_0x4f60('0x1'))['db'][_0x4f60('0x2')];var ChatMessage=require(_0x4f60('0x1'))['db'][_0x4f60('0x3')];var ChatInteractionEvents=new EventEmitter();ChatInteractionEvents['setMaxListeners'](0x0);var events={'afterCreate':_0x4f60('0x4'),'afterUpdate':_0x4f60('0x5'),'afterDestroy':'remove'};function emitEvent(_0x4df399){return function(_0x10da6d,_0x5a37dc,_0xf4caef){_0x10da6d[_0x4f60('0x6')]({'attributes':['id'],'raw':!![]})[_0x4f60('0x7')](function(_0x154b5c){_0x10da6d[_0x4f60('0x8')](_0x4f60('0x9'),_0x154b5c[_0x4f60('0xa')](function(_0x3439d9){return{'id':_0x3439d9['id']};}));return ChatMessage[_0x4f60('0xb')]({'where':{'ChatInteractionId':_0x10da6d['id'],'direction':'in','read':![]},'raw':!![]});})[_0x4f60('0x7')](function(_0x59a4f6){_0x10da6d[_0x4f60('0x8')](_0x4f60('0xc'),_0x59a4f6[_0x4f60('0xd')]);ChatInteractionEvents[_0x4f60('0xe')](_0x4df399+':'+_0x10da6d['id'],_0x10da6d);ChatInteractionEvents[_0x4f60('0xe')](_0x4df399,_0x10da6d);_0xf4caef(null);})[_0x4f60('0xf')](_0xf4caef(null));};}for(var e in events){if(events['hasOwnProperty'](e)){var event=events[e];ChatInteraction[_0x4f60('0x10')](e,emitEvent(event));}}module['exports']=ChatInteractionEvents;