Built motion from commit (unavailable).|2.5.4
[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 _0x23f2=['unreadMessages','length','emit','catch','hasOwnProperty','hook','exports','events','../../mysqldb','OpenchannelInteraction','OpenchannelMessage','setMaxListeners','save','update','then','setDataValue','Users','map','findAll'];(function(_0x501510,_0x61caa9){var _0x1e6ee5=function(_0x32845b){while(--_0x32845b){_0x501510['push'](_0x501510['shift']());}};_0x1e6ee5(++_0x61caa9);}(_0x23f2,0x137));var _0x223f=function(_0x1116ef,_0x225946){_0x1116ef=_0x1116ef-0x0;var _0x2af2cc=_0x23f2[_0x1116ef];return _0x2af2cc;};'use strict';var EventEmitter=require(_0x223f('0x0'));var OpenchannelInteraction=require(_0x223f('0x1'))['db'][_0x223f('0x2')];var OpenchannelMessage=require('../../mysqldb')['db'][_0x223f('0x3')];var OpenchannelInteractionEvents=new EventEmitter();OpenchannelInteractionEvents[_0x223f('0x4')](0x0);var events={'afterCreate':_0x223f('0x5'),'afterUpdate':_0x223f('0x6'),'afterDestroy':'remove'};function emitEvent(_0x2c0e54){return function(_0x90e5b2,_0x5c1884,_0x386c37){_0x90e5b2['getUsers']({'attributes':['id'],'raw':!![]})[_0x223f('0x7')](function(_0x375f4b){_0x90e5b2[_0x223f('0x8')](_0x223f('0x9'),_0x375f4b[_0x223f('0xa')](function(_0x3a0cb8){return{'id':_0x3a0cb8['id']};}));return OpenchannelMessage[_0x223f('0xb')]({'where':{'OpenchannelInteractionId':_0x90e5b2['id'],'direction':'in','read':![]},'raw':!![]});})[_0x223f('0x7')](function(_0x24229c){_0x90e5b2['setDataValue'](_0x223f('0xc'),_0x24229c[_0x223f('0xd')]);OpenchannelInteractionEvents[_0x223f('0xe')](_0x2c0e54+':'+_0x90e5b2['id'],_0x90e5b2);OpenchannelInteractionEvents[_0x223f('0xe')](_0x2c0e54,_0x90e5b2);_0x386c37(null);})[_0x223f('0xf')](_0x386c37(null));};}for(var e in events){if(events[_0x223f('0x10')](e)){var event=events[e];OpenchannelInteraction[_0x223f('0x11')](e,emitEvent(event));}}module[_0x223f('0x12')]=OpenchannelInteractionEvents;