Built motion from commit ddca4d0d.|2.5.47
[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 _0x2272=['findAll','unreadMessages','length','emit','catch','hook','exports','events','../../mysqldb','SmsInteraction','SmsMessage','save','update','remove','getUsers','then','setDataValue','Users','map'];(function(_0x2aea9e,_0x1f587f){var _0x430b92=function(_0x416c37){while(--_0x416c37){_0x2aea9e['push'](_0x2aea9e['shift']());}};_0x430b92(++_0x1f587f);}(_0x2272,0xd8));var _0x2227=function(_0xa464c9,_0x7c86d8){_0xa464c9=_0xa464c9-0x0;var _0x3d73c4=_0x2272[_0xa464c9];return _0x3d73c4;};'use strict';var EventEmitter=require(_0x2227('0x0'));var SmsInteraction=require(_0x2227('0x1'))['db'][_0x2227('0x2')];var SmsMessage=require(_0x2227('0x1'))['db'][_0x2227('0x3')];var SmsInteractionEvents=new EventEmitter();SmsInteractionEvents['setMaxListeners'](0x0);var events={'afterCreate':_0x2227('0x4'),'afterUpdate':_0x2227('0x5'),'afterDestroy':_0x2227('0x6')};function emitEvent(_0x4c17c2){return function(_0x4ebde3,_0x1e5a8a,_0x3b8661){_0x4ebde3[_0x2227('0x7')]({'attributes':['id'],'raw':!![]})[_0x2227('0x8')](function(_0xaec623){_0x4ebde3[_0x2227('0x9')](_0x2227('0xa'),_0xaec623[_0x2227('0xb')](function(_0x18094d){return{'id':_0x18094d['id']};}));return SmsMessage[_0x2227('0xc')]({'where':{'SmsInteractionId':_0x4ebde3['id'],'direction':'in','read':![]},'raw':!![]});})['then'](function(_0x799370){_0x4ebde3['setDataValue'](_0x2227('0xd'),_0x799370[_0x2227('0xe')]);SmsInteractionEvents[_0x2227('0xf')](_0x4c17c2+':'+_0x4ebde3['id'],_0x4ebde3);SmsInteractionEvents[_0x2227('0xf')](_0x4c17c2,_0x4ebde3);_0x3b8661(null);})[_0x2227('0x10')](_0x3b8661(null));};}for(var e in events){if(events['hasOwnProperty'](e)){var event=events[e];SmsInteraction[_0x2227('0x11')](e,emitEvent(event));}}module[_0x2227('0x12')]=SmsInteractionEvents;