Built motion from commit 1fa89557.|2.6.10
[motion2.git] / server / components / interaction / update-interaction.js
index b1fc4b4..f18d14e 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb8ae=['catch','updateInteraction','Users','TagIds','Tags','lodash','../../mysqldb','map','fullname','split','push','waiting','talking','answered','unmanaged','total','closed','abandoned','UserId','disposition','MailMessage','findOne','plainBody','then','lastMsgText','trimStart'];(function(_0x5685f7,_0x53e368){var _0x446dab=function(_0x4150c9){while(--_0x4150c9){_0x5685f7['push'](_0x5685f7['shift']());}};_0x446dab(++_0x53e368);}(_0xb8ae,0x18b));var _0xeb8a=function(_0x27af45,_0x1b57aa){_0x27af45=_0x27af45-0x0;var _0x18df21=_0xb8ae[_0x27af45];return _0x18df21;};'use strict';var _=require(_0xeb8a('0x0'));var db=require(_0xeb8a('0x1'))['db'];function getInteractionUsers(_0x4aca54,_0x1a6ae5){return new Promise(function(_0x3eacd6,_0x515f56){try{var _0x131ec4=[];if(_0x1a6ae5[_0x4aca54]){_0x131ec4=_0x1a6ae5[_0x4aca54][_0xeb8a('0x2')](function(_0x2259ea){return{'id':_0x2259ea['id'],'fullname':_0x2259ea[_0xeb8a('0x3')]};});}return _0x3eacd6(_0x131ec4);}catch(_0x17b453){_0x515f56(_0x17b453);}});}function getInteractionTags(_0x550b13,_0xebd586){var _0x5943d1=[];if(_0x550b13){_0x550b13[_0xeb8a('0x4')](',')['forEach'](function(_0x134ece){_0x5943d1[_0xeb8a('0x5')](_0xebd586[_0x134ece]);});}return _0x5943d1;}function updateWaitingCounter(_0x2a8805){if(_0x2a8805['waiting']){_0x2a8805[_0xeb8a('0x6')]-=0x1;}}function updateInteractionCounters(_0x373bba){_0x373bba[_0xeb8a('0x6')]=0x0;_0x373bba[_0xeb8a('0x7')]=0x0;_0x373bba[_0xeb8a('0x8')]=0x0;_0x373bba[_0xeb8a('0x9')]=0x0;_0x373bba['abandoned']=0x0;_0x373bba[_0xeb8a('0xa')]=0x0;if(_0x373bba[_0xeb8a('0xb')]){if(_0x373bba['disposition']==='abandoned'){_0x373bba[_0xeb8a('0xc')]+=0x1;updateWaitingCounter(_0x373bba);}if(_0x373bba[_0xeb8a('0xd')]){_0x373bba[_0xeb8a('0x8')]+=0x1;if(_0x373bba['talking']){_0x373bba[_0xeb8a('0x7')]-=0x1;}}else{if(_0x373bba[_0xeb8a('0xe')]){_0x373bba[_0xeb8a('0x9')]+=0x1;updateWaitingCounter(_0x373bba);}}}else{if(!_0x373bba[_0xeb8a('0xd')]){_0x373bba[_0xeb8a('0x6')]+=0x1;}if(_0x373bba['UserId']){_0x373bba['talking']+=0x1;updateWaitingCounter(_0x373bba);}}_0x373bba[_0xeb8a('0xa')]+=0x1;return _0x373bba;}function getLastMessageText(_0x4a7191){return db[_0xeb8a('0xf')][_0xeb8a('0x10')]({'where':{'$and':[{'MailInteractionId':_0x4a7191['id']},{'$or':[{'direction':'in'},{'$and':[{'direction':'out'},{'secret':![]},{'UserId':{'$ne':null}}]}]}]},'attributes':[_0xeb8a('0x11')],'order':'-id','raw':!![]})[_0xeb8a('0x12')](function(_0x1ae1ed){if(_0x1ae1ed&&_0x1ae1ed[_0xeb8a('0x11')]){_0x4a7191[_0xeb8a('0x13')]=_[_0xeb8a('0x14')](_0x1ae1ed[_0xeb8a('0x11')]);}return _0x4a7191;})[_0xeb8a('0x15')](function(_0xb3449f){throw _0xb3449f;});}exports[_0xeb8a('0x16')]=function(_0x545bda,_0x5c0146,_0x2d60d6,_0x3f8924){return new Promise(function(_0xebb3ea,_0x5e66d4){return getInteractionUsers(_0x545bda['id'],_0x2d60d6)[_0xeb8a('0x12')](function(_0x4780f2){_0x545bda[_0xeb8a('0x17')]=_0x4780f2;return getInteractionTags(_0x545bda[_0xeb8a('0x18')],_0x5c0146);})['then'](function(_0x2a2a10){_0x545bda[_0xeb8a('0x19')]=_0x2a2a10;delete _0x545bda[_0xeb8a('0x18')];return updateInteractionCounters(_0x545bda);})[_0xeb8a('0x12')](function(_0x29b126){if(_0x3f8924){return getLastMessageText(_0x29b126);}else{return _0x29b126;}})[_0xeb8a('0x12')](function(_0x523d91){_0xebb3ea(_0x523d91);})[_0xeb8a('0x15')](function(_0x27d240){_0x5e66d4(_0x27d240);});});};
\ No newline at end of file
+var _0x6ed4=['Users','TagIds','Tags','lodash','../../mysqldb','map','fullname','split','forEach','push','waiting','talking','answered','unmanaged','abandoned','total','closed','disposition','UserId','MailMessage','findOne','plainBody','-id','then','lastMsgText','trimStart','catch','updateInteraction'];(function(_0x1bd3ab,_0x352c42){var _0x37e394=function(_0x2f581d){while(--_0x2f581d){_0x1bd3ab['push'](_0x1bd3ab['shift']());}};_0x37e394(++_0x352c42);}(_0x6ed4,0xab));var _0x46ed=function(_0x23f9ba,_0x42b5dd){_0x23f9ba=_0x23f9ba-0x0;var _0x23010a=_0x6ed4[_0x23f9ba];return _0x23010a;};'use strict';var _=require(_0x46ed('0x0'));var db=require(_0x46ed('0x1'))['db'];function getInteractionUsers(_0x5b85f7,_0xe33d29){return new Promise(function(_0x1bb737,_0x3c16a2){try{var _0x280fbb=[];if(_0xe33d29[_0x5b85f7]){_0x280fbb=_0xe33d29[_0x5b85f7][_0x46ed('0x2')](function(_0xdf90f5){return{'id':_0xdf90f5['id'],'fullname':_0xdf90f5[_0x46ed('0x3')]};});}return _0x1bb737(_0x280fbb);}catch(_0x1ed5fc){_0x3c16a2(_0x1ed5fc);}});}function getInteractionTags(_0x312db2,_0x5ecb61){var _0x443b62=[];if(_0x312db2){_0x312db2[_0x46ed('0x4')](',')[_0x46ed('0x5')](function(_0x244629){_0x443b62[_0x46ed('0x6')](_0x5ecb61[_0x244629]);});}return _0x443b62;}function updateWaitingCounter(_0x4bd54e){if(_0x4bd54e[_0x46ed('0x7')]){_0x4bd54e['waiting']-=0x1;}}function updateInteractionCounters(_0x3077cd){_0x3077cd[_0x46ed('0x7')]=0x0;_0x3077cd[_0x46ed('0x8')]=0x0;_0x3077cd[_0x46ed('0x9')]=0x0;_0x3077cd[_0x46ed('0xa')]=0x0;_0x3077cd[_0x46ed('0xb')]=0x0;_0x3077cd[_0x46ed('0xc')]=0x0;if(_0x3077cd[_0x46ed('0xd')]){if(_0x3077cd[_0x46ed('0xe')]===_0x46ed('0xb')){_0x3077cd[_0x46ed('0xb')]+=0x1;updateWaitingCounter(_0x3077cd);}if(_0x3077cd[_0x46ed('0xf')]){_0x3077cd['answered']+=0x1;if(_0x3077cd[_0x46ed('0x8')]){_0x3077cd[_0x46ed('0x8')]-=0x1;}}else{if(_0x3077cd[_0x46ed('0xe')]){_0x3077cd[_0x46ed('0xa')]+=0x1;updateWaitingCounter(_0x3077cd);}}}else{if(!_0x3077cd[_0x46ed('0xf')]){_0x3077cd['waiting']+=0x1;}if(_0x3077cd['UserId']){_0x3077cd[_0x46ed('0x8')]+=0x1;updateWaitingCounter(_0x3077cd);}}_0x3077cd[_0x46ed('0xc')]+=0x1;return _0x3077cd;}function getLastMessageText(_0x432ba0){return db[_0x46ed('0x10')][_0x46ed('0x11')]({'where':{'$and':[{'MailInteractionId':_0x432ba0['id']},{'$or':[{'direction':'in'},{'$and':[{'direction':'out'},{'secret':![]},{'UserId':{'$ne':null}}]}]}]},'attributes':[_0x46ed('0x12')],'order':_0x46ed('0x13'),'raw':!![]})[_0x46ed('0x14')](function(_0xdea265){if(_0xdea265&&_0xdea265[_0x46ed('0x12')]){_0x432ba0[_0x46ed('0x15')]=_[_0x46ed('0x16')](_0xdea265[_0x46ed('0x12')]);}return _0x432ba0;})[_0x46ed('0x17')](function(_0x19998a){throw _0x19998a;});}exports[_0x46ed('0x18')]=function(_0xb1cfbf,_0x4275c2,_0x55a1c0,_0x4f1729){return new Promise(function(_0x2118eb,_0x4ea000){return getInteractionUsers(_0xb1cfbf['id'],_0x55a1c0)[_0x46ed('0x14')](function(_0xdb4539){_0xb1cfbf[_0x46ed('0x19')]=_0xdb4539;return getInteractionTags(_0xb1cfbf[_0x46ed('0x1a')],_0x4275c2);})[_0x46ed('0x14')](function(_0x11ebfd){_0xb1cfbf[_0x46ed('0x1b')]=_0x11ebfd;delete _0xb1cfbf[_0x46ed('0x1a')];return updateInteractionCounters(_0xb1cfbf);})['then'](function(_0xd3e693){if(_0x4f1729){return getLastMessageText(_0xd3e693);}else{return _0xd3e693;}})[_0x46ed('0x14')](function(_0x2bf726){_0x2118eb(_0x2bf726);})['catch'](function(_0xd4670e){_0x4ea000(_0xd4670e);});});};
\ No newline at end of file