Built motion from commit (unavailable).|2.4.4
[motion2.git] / server / api / chatInteraction / chatInteraction.events.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
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.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x8f3d=['emit','catch','../../mysqldb','ChatInteraction','setMaxListeners','save','remove','getUsers','then','Users','map','findAll','unreadMessages','length'];(function(_0x2da23b,_0x4148e2){var _0x2c1162=function(_0xad24e2){while(--_0xad24e2){_0x2da23b['push'](_0x2da23b['shift']());}};_0x2c1162(++_0x4148e2);}(_0x8f3d,0xd4));var _0xd8f3=function(_0x3957c7,_0x4ed15a){_0x3957c7=_0x3957c7-0x0;var _0x2c40e2=_0x8f3d[_0x3957c7];return _0x2c40e2;};'use strict';var EventEmitter=require('events');var ChatInteraction=require(_0xd8f3('0x0'))['db'][_0xd8f3('0x1')];var ChatMessage=require(_0xd8f3('0x0'))['db']['ChatMessage'];var ChatInteractionEvents=new EventEmitter();ChatInteractionEvents[_0xd8f3('0x2')](0x0);var events={'afterCreate':_0xd8f3('0x3'),'afterUpdate':'update','afterDestroy':_0xd8f3('0x4')};function emitEvent(_0x22fc13){return function(_0x36f9b1,_0x35edf8,_0x3b76e8){_0x36f9b1[_0xd8f3('0x5')]({'attributes':['id'],'raw':!![]})[_0xd8f3('0x6')](function(_0x59d3a7){_0x36f9b1['setDataValue'](_0xd8f3('0x7'),_0x59d3a7[_0xd8f3('0x8')](function(_0x47a992){return{'id':_0x47a992['id']};}));return ChatMessage[_0xd8f3('0x9')]({'where':{'ChatInteractionId':_0x36f9b1['id'],'direction':'in','read':![]},'raw':!![]});})[_0xd8f3('0x6')](function(_0x193c58){_0x36f9b1['setDataValue'](_0xd8f3('0xa'),_0x193c58[_0xd8f3('0xb')]);ChatInteractionEvents[_0xd8f3('0xc')](_0x22fc13+':'+_0x36f9b1['id'],_0x36f9b1);ChatInteractionEvents[_0xd8f3('0xc')](_0x22fc13,_0x36f9b1);_0x3b76e8(null);})[_0xd8f3('0xd')](_0x3b76e8(null));};}for(var e in events){if(events['hasOwnProperty'](e)){var event=events[e];ChatInteraction['hook'](e,emitEvent(event));}}module['exports']=ChatInteractionEvents;