Built motion from commit 9d0783e6.|2.6.13
[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 _0x804e=['update','remove','getUsers','then','setDataValue','Users','map','findAll','length','emit','catch','hasOwnProperty','exports','events','../../mysqldb','ChatInteraction','ChatMessage','save'];(function(_0x242ecf,_0xcbeb0){var _0x5c8971=function(_0x234cfd){while(--_0x234cfd){_0x242ecf['push'](_0x242ecf['shift']());}};_0x5c8971(++_0xcbeb0);}(_0x804e,0x79));var _0xe804=function(_0x535bf6,_0x43a5ae){_0x535bf6=_0x535bf6-0x0;var _0x5d764c=_0x804e[_0x535bf6];return _0x5d764c;};'use strict';var EventEmitter=require(_0xe804('0x0'));var ChatInteraction=require(_0xe804('0x1'))['db'][_0xe804('0x2')];var ChatMessage=require('../../mysqldb')['db'][_0xe804('0x3')];var ChatInteractionEvents=new EventEmitter();ChatInteractionEvents['setMaxListeners'](0x0);var events={'afterCreate':_0xe804('0x4'),'afterUpdate':_0xe804('0x5'),'afterDestroy':_0xe804('0x6')};function emitEvent(_0x19e812){return function(_0x5e52ab,_0x15cbaf,_0xe4d772){_0x5e52ab[_0xe804('0x7')]({'attributes':['id'],'raw':!![]})[_0xe804('0x8')](function(_0x274ce){_0x5e52ab[_0xe804('0x9')](_0xe804('0xa'),_0x274ce[_0xe804('0xb')](function(_0x813e3f){return{'id':_0x813e3f['id']};}));return ChatMessage[_0xe804('0xc')]({'where':{'ChatInteractionId':_0x5e52ab['id'],'direction':'in','read':![]},'raw':!![]});})[_0xe804('0x8')](function(_0x311139){_0x5e52ab[_0xe804('0x9')]('unreadMessages',_0x311139[_0xe804('0xd')]);ChatInteractionEvents[_0xe804('0xe')](_0x19e812+':'+_0x5e52ab['id'],_0x5e52ab);ChatInteractionEvents[_0xe804('0xe')](_0x19e812,_0x5e52ab);_0xe4d772(null);})[_0xe804('0xf')](_0xe4d772(null));};}for(var e in events){if(events[_0xe804('0x10')](e)){var event=events[e];ChatInteraction['hook'](e,emitEvent(event));}}module[_0xe804('0x11')]=ChatInteractionEvents;