Built motion from commit f67b3b02.|2.6.31
[motion2.git] / server / components / interaction / update-interaction.js
index 805c33a..6702004 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x34cf=['updateInteraction','then','TagIds','../../mysqldb','fullname','waiting','unmanaged','abandoned','total','closed','disposition','UserId','answered','talking','MailMessage','out','plainBody','trimStart','catch'];(function(_0x2a9f4,_0x25c14a){var _0x3c39e0=function(_0x3b8deb){while(--_0x3b8deb){_0x2a9f4['push'](_0x2a9f4['shift']());}};_0x3c39e0(++_0x25c14a);}(_0x34cf,0x1a5));var _0xf34c=function(_0xd0881b,_0x5d73b8){_0xd0881b=_0xd0881b-0x0;var _0x50f1e7=_0x34cf[_0xd0881b];return _0x50f1e7;};'use strict';var _=require('lodash');var db=require(_0xf34c('0x0'))['db'];function getInteractionUsers(_0x1b0afc,_0x43e3a0){return new Promise(function(_0x5c1568,_0xcf7dca){try{var _0x1fb2c7=[];if(_0x43e3a0[_0x1b0afc]){_0x1fb2c7=_0x43e3a0[_0x1b0afc]['map'](function(_0x431b56){return{'id':_0x431b56['id'],'fullname':_0x431b56[_0xf34c('0x1')]};});}return _0x5c1568(_0x1fb2c7);}catch(_0x5be815){_0xcf7dca(_0x5be815);}});}function getInteractionTags(_0x4ba7ae,_0x1d8d14){var _0x9f0f6e=[];if(_0x4ba7ae){_0x4ba7ae['split'](',')['forEach'](function(_0x9d5642){_0x9f0f6e['push'](_0x1d8d14[_0x9d5642]);});}return _0x9f0f6e;}function updateWaitingCounter(_0x37f9a7){if(_0x37f9a7[_0xf34c('0x2')]){_0x37f9a7[_0xf34c('0x2')]-=0x1;}}function updateInteractionCounters(_0x3b9427){_0x3b9427[_0xf34c('0x2')]=0x0;_0x3b9427['talking']=0x0;_0x3b9427['answered']=0x0;_0x3b9427[_0xf34c('0x3')]=0x0;_0x3b9427[_0xf34c('0x4')]=0x0;_0x3b9427[_0xf34c('0x5')]=0x0;if(_0x3b9427[_0xf34c('0x6')]){if(_0x3b9427[_0xf34c('0x7')]===_0xf34c('0x4')){_0x3b9427['abandoned']+=0x1;updateWaitingCounter(_0x3b9427);}if(_0x3b9427[_0xf34c('0x8')]){_0x3b9427[_0xf34c('0x9')]+=0x1;if(_0x3b9427[_0xf34c('0xa')]){_0x3b9427[_0xf34c('0xa')]-=0x1;}}else{if(_0x3b9427[_0xf34c('0x7')]){_0x3b9427[_0xf34c('0x3')]+=0x1;updateWaitingCounter(_0x3b9427);}}}else{if(!_0x3b9427[_0xf34c('0x8')]){_0x3b9427[_0xf34c('0x2')]+=0x1;}if(_0x3b9427['UserId']){_0x3b9427[_0xf34c('0xa')]+=0x1;updateWaitingCounter(_0x3b9427);}}_0x3b9427['total']+=0x1;return _0x3b9427;}function getLastMessageText(_0x48458f){return db[_0xf34c('0xb')]['findOne']({'where':{'$and':[{'MailInteractionId':_0x48458f['id']},{'$or':[{'direction':'in'},{'$and':[{'direction':_0xf34c('0xc')},{'secret':![]},{'UserId':{'$ne':null}}]}]}]},'attributes':[_0xf34c('0xd')],'order':'-id','raw':!![]})['then'](function(_0x5e4104){if(_0x5e4104&&_0x5e4104[_0xf34c('0xd')]){_0x48458f['lastMsgText']=_[_0xf34c('0xe')](_0x5e4104[_0xf34c('0xd')]);}return _0x48458f;})[_0xf34c('0xf')](function(_0x2763e7){throw _0x2763e7;});}exports[_0xf34c('0x10')]=function(_0x422088,_0x3ae752,_0x3131f6,_0x40ea0a){return new Promise(function(_0x5e4ef8,_0x20e89f){return getInteractionUsers(_0x422088['id'],_0x3131f6)[_0xf34c('0x11')](function(_0x359ce3){_0x422088['Users']=_0x359ce3;return getInteractionTags(_0x422088['TagIds'],_0x3ae752);})[_0xf34c('0x11')](function(_0x525cd0){_0x422088['Tags']=_0x525cd0;delete _0x422088[_0xf34c('0x12')];return updateInteractionCounters(_0x422088);})[_0xf34c('0x11')](function(_0x3ef3e0){if(_0x40ea0a){return getLastMessageText(_0x3ef3e0);}else{return _0x3ef3e0;}})[_0xf34c('0x11')](function(_0x2353b8){_0x5e4ef8(_0x2353b8);})[_0xf34c('0xf')](function(_0x407e27){_0x20e89f(_0x407e27);});});};
\ No newline at end of file
+var _0x05f2=['TagIds','then','Tags','lodash','../../mysqldb','fullname','split','waiting','talking','answered','unmanaged','abandoned','total','disposition','UserId','MailMessage','findOne','out','plainBody','-id','lastMsgText','trimStart','catch','Users'];(function(_0x2f82e7,_0x50f448){var _0x483927=function(_0x1f9d9c){while(--_0x1f9d9c){_0x2f82e7['push'](_0x2f82e7['shift']());}};_0x483927(++_0x50f448);}(_0x05f2,0x16b));var _0x205f=function(_0x42cae2,_0x284ef8){_0x42cae2=_0x42cae2-0x0;var _0x5f256f=_0x05f2[_0x42cae2];return _0x5f256f;};'use strict';var _=require(_0x205f('0x0'));var db=require(_0x205f('0x1'))['db'];function getInteractionUsers(_0x26b146,_0x17daef){return new Promise(function(_0x3e1849,_0x2015d4){try{var _0x9fabbc=[];if(_0x17daef[_0x26b146]){_0x9fabbc=_0x17daef[_0x26b146]['map'](function(_0x187d73){return{'id':_0x187d73['id'],'fullname':_0x187d73[_0x205f('0x2')]};});}return _0x3e1849(_0x9fabbc);}catch(_0x481235){_0x2015d4(_0x481235);}});}function getInteractionTags(_0x43307b,_0x157eab){var _0x4e8693=[];if(_0x43307b){_0x43307b[_0x205f('0x3')](',')['forEach'](function(_0x35824a){_0x4e8693['push'](_0x157eab[_0x35824a]);});}return _0x4e8693;}function updateWaitingCounter(_0x1fd29b){if(_0x1fd29b[_0x205f('0x4')]){_0x1fd29b[_0x205f('0x4')]-=0x1;}}function updateInteractionCounters(_0x517784){_0x517784[_0x205f('0x4')]=0x0;_0x517784[_0x205f('0x5')]=0x0;_0x517784[_0x205f('0x6')]=0x0;_0x517784[_0x205f('0x7')]=0x0;_0x517784[_0x205f('0x8')]=0x0;_0x517784[_0x205f('0x9')]=0x0;if(_0x517784['closed']){if(_0x517784[_0x205f('0xa')]===_0x205f('0x8')){_0x517784['abandoned']+=0x1;updateWaitingCounter(_0x517784);}if(_0x517784[_0x205f('0xb')]){_0x517784['answered']+=0x1;if(_0x517784['talking']){_0x517784[_0x205f('0x5')]-=0x1;}}else{if(_0x517784[_0x205f('0xa')]){_0x517784['unmanaged']+=0x1;updateWaitingCounter(_0x517784);}}}else{if(!_0x517784['UserId']){_0x517784[_0x205f('0x4')]+=0x1;}if(_0x517784[_0x205f('0xb')]){_0x517784[_0x205f('0x5')]+=0x1;updateWaitingCounter(_0x517784);}}_0x517784[_0x205f('0x9')]+=0x1;return _0x517784;}function getLastMessageText(_0x4a094a){return db[_0x205f('0xc')][_0x205f('0xd')]({'where':{'$and':[{'MailInteractionId':_0x4a094a['id']},{'$or':[{'direction':'in'},{'$and':[{'direction':_0x205f('0xe')},{'secret':![]},{'UserId':{'$ne':null}}]}]}]},'attributes':[_0x205f('0xf')],'order':_0x205f('0x10'),'raw':!![]})['then'](function(_0x126173){if(_0x126173&&_0x126173['plainBody']){_0x4a094a[_0x205f('0x11')]=_[_0x205f('0x12')](_0x126173[_0x205f('0xf')]);}return _0x4a094a;})[_0x205f('0x13')](function(_0x3c4eaa){throw _0x3c4eaa;});}exports['updateInteraction']=function(_0x3e9e51,_0x31f3c8,_0x64a19,_0x581125){return new Promise(function(_0x359b49,_0x209a08){return getInteractionUsers(_0x3e9e51['id'],_0x64a19)['then'](function(_0x351512){_0x3e9e51[_0x205f('0x14')]=_0x351512;return getInteractionTags(_0x3e9e51[_0x205f('0x15')],_0x31f3c8);})[_0x205f('0x16')](function(_0x4cffba){_0x3e9e51[_0x205f('0x17')]=_0x4cffba;delete _0x3e9e51[_0x205f('0x15')];return updateInteractionCounters(_0x3e9e51);})[_0x205f('0x16')](function(_0x52c74a){if(_0x581125){return getLastMessageText(_0x52c74a);}else{return _0x52c74a;}})['then'](function(_0x5aac1b){_0x359b49(_0x5aac1b);})[_0x205f('0x13')](function(_0x3e99a8){_0x209a08(_0x3e99a8);});});};
\ No newline at end of file