Built motion from commit 5b761a7b.|2.5.36
[motion2.git] / server / api / smsInteraction / smsInteraction.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 _0xc2c7=['setDataValue','unreadMessages','length','emit','catch','hasOwnProperty','hook','exports','../../mysqldb','SmsInteraction','SmsMessage','setMaxListeners','save','update','remove','getUsers','Users','map','findAll','then'];(function(_0x551811,_0x47e00c){var _0x2e14a7=function(_0x4095b5){while(--_0x4095b5){_0x551811['push'](_0x551811['shift']());}};_0x2e14a7(++_0x47e00c);}(_0xc2c7,0x134));var _0x7c2c=function(_0x1e9e70,_0x106e2d){_0x1e9e70=_0x1e9e70-0x0;var _0x2896c7=_0xc2c7[_0x1e9e70];return _0x2896c7;};'use strict';var EventEmitter=require('events');var SmsInteraction=require(_0x7c2c('0x0'))['db'][_0x7c2c('0x1')];var SmsMessage=require(_0x7c2c('0x0'))['db'][_0x7c2c('0x2')];var SmsInteractionEvents=new EventEmitter();SmsInteractionEvents[_0x7c2c('0x3')](0x0);var events={'afterCreate':_0x7c2c('0x4'),'afterUpdate':_0x7c2c('0x5'),'afterDestroy':_0x7c2c('0x6')};function emitEvent(_0x4bbc14){return function(_0x59f346,_0x31dc4e,_0x42ecc9){_0x59f346[_0x7c2c('0x7')]({'attributes':['id'],'raw':!![]})['then'](function(_0x4abe93){_0x59f346['setDataValue'](_0x7c2c('0x8'),_0x4abe93[_0x7c2c('0x9')](function(_0x3e668f){return{'id':_0x3e668f['id']};}));return SmsMessage[_0x7c2c('0xa')]({'where':{'SmsInteractionId':_0x59f346['id'],'direction':'in','read':![]},'raw':!![]});})[_0x7c2c('0xb')](function(_0x57b107){_0x59f346[_0x7c2c('0xc')](_0x7c2c('0xd'),_0x57b107[_0x7c2c('0xe')]);SmsInteractionEvents[_0x7c2c('0xf')](_0x4bbc14+':'+_0x59f346['id'],_0x59f346);SmsInteractionEvents[_0x7c2c('0xf')](_0x4bbc14,_0x59f346);_0x42ecc9(null);})[_0x7c2c('0x10')](_0x42ecc9(null));};}for(var e in events){if(events[_0x7c2c('0x11')](e)){var event=events[e];SmsInteraction[_0x7c2c('0x12')](e,emitEvent(event));}}module[_0x7c2c('0x13')]=SmsInteractionEvents;