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 _0x7df8=['findAll','unreadMessages','length','emit','catch','hasOwnProperty','hook','events','../../mysqldb','OpenchannelInteraction','OpenchannelMessage','save','update','remove','getUsers','then','setDataValue','Users','map'];(function(_0x42e57a,_0x206d5d){var _0x37b280=function(_0x24ac26){while(--_0x24ac26){_0x42e57a['push'](_0x42e57a['shift']());}};_0x37b280(++_0x206d5d);}(_0x7df8,0x1e2));var _0x87df=function(_0x5708b0,_0xfbf56c){_0x5708b0=_0x5708b0-0x0;var _0x2fcbe0=_0x7df8[_0x5708b0];return _0x2fcbe0;};'use strict';var EventEmitter=require(_0x87df('0x0'));var OpenchannelInteraction=require(_0x87df('0x1'))['db'][_0x87df('0x2')];var OpenchannelMessage=require('../../mysqldb')['db'][_0x87df('0x3')];var OpenchannelInteractionEvents=new EventEmitter();OpenchannelInteractionEvents['setMaxListeners'](0x0);var events={'afterCreate':_0x87df('0x4'),'afterUpdate':_0x87df('0x5'),'afterDestroy':_0x87df('0x6')};function emitEvent(_0x4ef640){return function(_0x31a28f,_0x3dbc12,_0x30a995){_0x31a28f[_0x87df('0x7')]({'attributes':['id'],'raw':!![]})[_0x87df('0x8')](function(_0x1a0076){_0x31a28f[_0x87df('0x9')](_0x87df('0xa'),_0x1a0076[_0x87df('0xb')](function(_0x478d58){return{'id':_0x478d58['id']};}));return OpenchannelMessage[_0x87df('0xc')]({'where':{'OpenchannelInteractionId':_0x31a28f['id'],'direction':'in','read':![]},'raw':!![]});})[_0x87df('0x8')](function(_0x471814){_0x31a28f[_0x87df('0x9')](_0x87df('0xd'),_0x471814[_0x87df('0xe')]);OpenchannelInteractionEvents[_0x87df('0xf')](_0x4ef640+':'+_0x31a28f['id'],_0x31a28f);OpenchannelInteractionEvents[_0x87df('0xf')](_0x4ef640,_0x31a28f);_0x30a995(null);})[_0x87df('0x10')](_0x30a995(null));};}for(var e in events){if(events[_0x87df('0x11')](e)){var event=events[e];OpenchannelInteraction[_0x87df('0x12')](e,emitEvent(event));}}module['exports']=OpenchannelInteractionEvents;