Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / smsInteraction / smsInteraction.events.js
index 74bf004..f1b8765 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xee14=['Users','map','unreadMessages','length','emit','hasOwnProperty','hook','exports','SmsInteraction','../../mysqldb','SmsMessage','setMaxListeners','save','update','remove','then','setDataValue'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xee14,0x13a));var _0x4ee1=function(_0x1c4be5,_0x28d332){_0x1c4be5=_0x1c4be5-0x0;var _0x70b8e8=_0xee14[_0x1c4be5];return _0x70b8e8;};'use strict';var EventEmitter=require('events');var SmsInteraction=require('../../mysqldb')['db'][_0x4ee1('0x0')];var SmsMessage=require(_0x4ee1('0x1'))['db'][_0x4ee1('0x2')];var SmsInteractionEvents=new EventEmitter();SmsInteractionEvents[_0x4ee1('0x3')](0x0);var events={'afterCreate':_0x4ee1('0x4'),'afterUpdate':_0x4ee1('0x5'),'afterDestroy':_0x4ee1('0x6')};function emitEvent(_0x1e5fb6){return function(_0x3ccbc6,_0x4bc729,_0xba6d36){_0x3ccbc6['getUsers']({'attributes':['id'],'raw':!![]})[_0x4ee1('0x7')](function(_0x3a45a3){_0x3ccbc6[_0x4ee1('0x8')](_0x4ee1('0x9'),_0x3a45a3[_0x4ee1('0xa')](function(_0x1fd8c8){return{'id':_0x1fd8c8['id']};}));return SmsMessage['findAll']({'where':{'SmsInteractionId':_0x3ccbc6['id'],'direction':'in','read':![]},'raw':!![]});})[_0x4ee1('0x7')](function(_0x38be25){_0x3ccbc6['setDataValue'](_0x4ee1('0xb'),_0x38be25[_0x4ee1('0xc')]);SmsInteractionEvents[_0x4ee1('0xd')](_0x1e5fb6+':'+_0x3ccbc6['id'],_0x3ccbc6);SmsInteractionEvents[_0x4ee1('0xd')](_0x1e5fb6,_0x3ccbc6);_0xba6d36(null);})['catch'](_0xba6d36(null));};}for(var e in events){if(events[_0x4ee1('0xe')](e)){var event=events[e];SmsInteraction[_0x4ee1('0xf')](e,emitEvent(event));}}module[_0x4ee1('0x10')]=SmsInteractionEvents;
\ No newline at end of file
+var _0x14a0=['hook','exports','../../mysqldb','SmsInteraction','SmsMessage','setMaxListeners','save','update','setDataValue','Users','findAll','length','emit','catch'];(function(_0x3b4e7b,_0x416d01){var _0xc353d2=function(_0x33696e){while(--_0x33696e){_0x3b4e7b['push'](_0x3b4e7b['shift']());}};_0xc353d2(++_0x416d01);}(_0x14a0,0x8e));var _0x014a=function(_0x4e7dd7,_0x3e7134){_0x4e7dd7=_0x4e7dd7-0x0;var _0x4f4461=_0x14a0[_0x4e7dd7];return _0x4f4461;};'use strict';var EventEmitter=require('events');var SmsInteraction=require(_0x014a('0x0'))['db'][_0x014a('0x1')];var SmsMessage=require(_0x014a('0x0'))['db'][_0x014a('0x2')];var SmsInteractionEvents=new EventEmitter();SmsInteractionEvents[_0x014a('0x3')](0x0);var events={'afterCreate':_0x014a('0x4'),'afterUpdate':_0x014a('0x5'),'afterDestroy':'remove'};function emitEvent(_0x57a522){return function(_0x1730a5,_0x12e8da,_0x38a22c){_0x1730a5['getUsers']({'attributes':['id'],'raw':!![]})['then'](function(_0x11b8ce){_0x1730a5[_0x014a('0x6')](_0x014a('0x7'),_0x11b8ce['map'](function(_0x5d3d7f){return{'id':_0x5d3d7f['id']};}));return SmsMessage[_0x014a('0x8')]({'where':{'SmsInteractionId':_0x1730a5['id'],'direction':'in','read':![]},'raw':!![]});})['then'](function(_0x490ea2){_0x1730a5['setDataValue']('unreadMessages',_0x490ea2[_0x014a('0x9')]);SmsInteractionEvents['emit'](_0x57a522+':'+_0x1730a5['id'],_0x1730a5);SmsInteractionEvents[_0x014a('0xa')](_0x57a522,_0x1730a5);_0x38a22c(null);})[_0x014a('0xb')](_0x38a22c(null));};}for(var e in events){if(events['hasOwnProperty'](e)){var event=events[e];SmsInteraction[_0x014a('0xc')](e,emitEvent(event));}}module[_0x014a('0xd')]=SmsInteractionEvents;
\ No newline at end of file