Built motion from commit (unavailable).|2.5.26
[motion2.git] / server / api / openchannelInteraction / openchannelInteraction.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 _0x4d1e=['OpenchannelInteraction','OpenchannelMessage','setMaxListeners','save','update','remove','getUsers','then','setDataValue','Users','map','length','emit','catch','hasOwnProperty','events','../../mysqldb'];(function(_0x4e0dce,_0x584875){var _0x154ed6=function(_0x2c2168){while(--_0x2c2168){_0x4e0dce['push'](_0x4e0dce['shift']());}};_0x154ed6(++_0x584875);}(_0x4d1e,0x1da));var _0xe4d1=function(_0x5d7227,_0x12aebe){_0x5d7227=_0x5d7227-0x0;var _0x15ac55=_0x4d1e[_0x5d7227];return _0x15ac55;};'use strict';var EventEmitter=require(_0xe4d1('0x0'));var OpenchannelInteraction=require(_0xe4d1('0x1'))['db'][_0xe4d1('0x2')];var OpenchannelMessage=require(_0xe4d1('0x1'))['db'][_0xe4d1('0x3')];var OpenchannelInteractionEvents=new EventEmitter();OpenchannelInteractionEvents[_0xe4d1('0x4')](0x0);var events={'afterCreate':_0xe4d1('0x5'),'afterUpdate':_0xe4d1('0x6'),'afterDestroy':_0xe4d1('0x7')};function emitEvent(_0x5abbf9){return function(_0x4e5c48,_0x53afe5,_0x1dbc12){_0x4e5c48[_0xe4d1('0x8')]({'attributes':['id'],'raw':!![]})[_0xe4d1('0x9')](function(_0x17c6c3){_0x4e5c48[_0xe4d1('0xa')](_0xe4d1('0xb'),_0x17c6c3[_0xe4d1('0xc')](function(_0x1cb94b){return{'id':_0x1cb94b['id']};}));return OpenchannelMessage['findAll']({'where':{'OpenchannelInteractionId':_0x4e5c48['id'],'direction':'in','read':![]},'raw':!![]});})[_0xe4d1('0x9')](function(_0x4e8e79){_0x4e5c48[_0xe4d1('0xa')]('unreadMessages',_0x4e8e79[_0xe4d1('0xd')]);OpenchannelInteractionEvents[_0xe4d1('0xe')](_0x5abbf9+':'+_0x4e5c48['id'],_0x4e5c48);OpenchannelInteractionEvents[_0xe4d1('0xe')](_0x5abbf9,_0x4e5c48);_0x1dbc12(null);})[_0xe4d1('0xf')](_0x1dbc12(null));};}for(var e in events){if(events[_0xe4d1('0x10')](e)){var event=events[e];OpenchannelInteraction['hook'](e,emitEvent(event));}}module['exports']=OpenchannelInteractionEvents;