Built motion from commit cb845558.|2.6.34
[motion2.git] / server / components / interaction / update-interaction.js
index 22dcafc..2bc00fc 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6fd6=['waiting','talking','unmanaged','total','closed','disposition','UserId','answered','MailMessage','findOne','out','plainBody','-id','lastMsgText','trimStart','catch','updateInteraction','Users','TagIds','Tags','then','lodash','../../mysqldb','map','fullname','split','forEach'];(function(_0x427272,_0x5a5946){var _0x41252f=function(_0x3f0ffa){while(--_0x3f0ffa){_0x427272['push'](_0x427272['shift']());}};_0x41252f(++_0x5a5946);}(_0x6fd6,0x81));var _0x66fd=function(_0x59cca4,_0x25319f){_0x59cca4=_0x59cca4-0x0;var _0x543df0=_0x6fd6[_0x59cca4];return _0x543df0;};'use strict';var _=require(_0x66fd('0x0'));var db=require(_0x66fd('0x1'))['db'];function getInteractionUsers(_0x2636aa,_0x14afd9){return new Promise(function(_0x1023d5,_0x1785e1){try{var _0x1ead8f=[];if(_0x14afd9[_0x2636aa]){_0x1ead8f=_0x14afd9[_0x2636aa][_0x66fd('0x2')](function(_0xdde160){return{'id':_0xdde160['id'],'fullname':_0xdde160[_0x66fd('0x3')]};});}return _0x1023d5(_0x1ead8f);}catch(_0x1801f1){_0x1785e1(_0x1801f1);}});}function getInteractionTags(_0x5172f4,_0x3c8118){var _0x150d26=[];if(_0x5172f4){_0x5172f4[_0x66fd('0x4')](',')[_0x66fd('0x5')](function(_0x42d509){_0x150d26['push'](_0x3c8118[_0x42d509]);});}return _0x150d26;}function updateWaitingCounter(_0x49b0da){if(_0x49b0da[_0x66fd('0x6')]){_0x49b0da[_0x66fd('0x6')]-=0x1;}}function updateInteractionCounters(_0x2fe5a3){_0x2fe5a3[_0x66fd('0x6')]=0x0;_0x2fe5a3[_0x66fd('0x7')]=0x0;_0x2fe5a3['answered']=0x0;_0x2fe5a3[_0x66fd('0x8')]=0x0;_0x2fe5a3['abandoned']=0x0;_0x2fe5a3[_0x66fd('0x9')]=0x0;if(_0x2fe5a3[_0x66fd('0xa')]){if(_0x2fe5a3[_0x66fd('0xb')]==='abandoned'){_0x2fe5a3['abandoned']+=0x1;updateWaitingCounter(_0x2fe5a3);}if(_0x2fe5a3[_0x66fd('0xc')]){_0x2fe5a3[_0x66fd('0xd')]+=0x1;if(_0x2fe5a3[_0x66fd('0x7')]){_0x2fe5a3[_0x66fd('0x7')]-=0x1;}}else{if(_0x2fe5a3['disposition']){_0x2fe5a3[_0x66fd('0x8')]+=0x1;updateWaitingCounter(_0x2fe5a3);}}}else{if(!_0x2fe5a3[_0x66fd('0xc')]){_0x2fe5a3['waiting']+=0x1;}if(_0x2fe5a3[_0x66fd('0xc')]){_0x2fe5a3['talking']+=0x1;updateWaitingCounter(_0x2fe5a3);}}_0x2fe5a3[_0x66fd('0x9')]+=0x1;return _0x2fe5a3;}function getLastMessageText(_0x40756d){return db[_0x66fd('0xe')][_0x66fd('0xf')]({'where':{'$and':[{'MailInteractionId':_0x40756d['id']},{'$or':[{'direction':'in'},{'$and':[{'direction':_0x66fd('0x10')},{'secret':![]},{'UserId':{'$ne':null}}]}]}]},'attributes':[_0x66fd('0x11')],'order':_0x66fd('0x12'),'raw':!![]})['then'](function(_0x4ad6f7){if(_0x4ad6f7&&_0x4ad6f7['plainBody']){_0x40756d[_0x66fd('0x13')]=_[_0x66fd('0x14')](_0x4ad6f7['plainBody']);}return _0x40756d;})[_0x66fd('0x15')](function(_0x485017){throw _0x485017;});}exports[_0x66fd('0x16')]=function(_0x3eb32e,_0xb23f7a,_0x47be30,_0x52a731){return new Promise(function(_0x22b397,_0x1b4c36){return getInteractionUsers(_0x3eb32e['id'],_0x47be30)['then'](function(_0x8c9b94){_0x3eb32e[_0x66fd('0x17')]=_0x8c9b94;return getInteractionTags(_0x3eb32e[_0x66fd('0x18')],_0xb23f7a);})['then'](function(_0x2e24ee){_0x3eb32e[_0x66fd('0x19')]=_0x2e24ee;delete _0x3eb32e[_0x66fd('0x18')];return updateInteractionCounters(_0x3eb32e);})[_0x66fd('0x1a')](function(_0x24d564){if(_0x52a731){return getLastMessageText(_0x24d564);}else{return _0x24d564;}})[_0x66fd('0x1a')](function(_0x5582ea){_0x22b397(_0x5582ea);})[_0x66fd('0x15')](function(_0x31cd68){_0x1b4c36(_0x31cd68);});});};
\ No newline at end of file
+var _0x2103=['push','waiting','talking','answered','abandoned','closed','disposition','unmanaged','UserId','total','MailMessage','findOne','out','plainBody','-id','then','lastMsgText','trimStart','catch','updateInteraction','Users','TagIds','Tags','lodash','map','fullname','forEach'];(function(_0x426751,_0x368e0b){var _0x2964af=function(_0x2070c1){while(--_0x2070c1){_0x426751['push'](_0x426751['shift']());}};_0x2964af(++_0x368e0b);}(_0x2103,0x1e2));var _0x3210=function(_0x4b369d,_0x265eb8){_0x4b369d=_0x4b369d-0x0;var _0x571a98=_0x2103[_0x4b369d];return _0x571a98;};'use strict';var _=require(_0x3210('0x0'));var db=require('../../mysqldb')['db'];function getInteractionUsers(_0x4970c0,_0x245834){return new Promise(function(_0x21f857,_0xf500ac){try{var _0x2baf5d=[];if(_0x245834[_0x4970c0]){_0x2baf5d=_0x245834[_0x4970c0][_0x3210('0x1')](function(_0x11ddc3){return{'id':_0x11ddc3['id'],'fullname':_0x11ddc3[_0x3210('0x2')]};});}return _0x21f857(_0x2baf5d);}catch(_0x450ab7){_0xf500ac(_0x450ab7);}});}function getInteractionTags(_0x1db88c,_0x33bf4e){var _0x8452b1=[];if(_0x1db88c){_0x1db88c['split'](',')[_0x3210('0x3')](function(_0xfb0013){_0x8452b1[_0x3210('0x4')](_0x33bf4e[_0xfb0013]);});}return _0x8452b1;}function updateWaitingCounter(_0x4c239c){if(_0x4c239c['waiting']){_0x4c239c['waiting']-=0x1;}}function updateInteractionCounters(_0x394e9d){_0x394e9d[_0x3210('0x5')]=0x0;_0x394e9d[_0x3210('0x6')]=0x0;_0x394e9d[_0x3210('0x7')]=0x0;_0x394e9d['unmanaged']=0x0;_0x394e9d[_0x3210('0x8')]=0x0;_0x394e9d['total']=0x0;if(_0x394e9d[_0x3210('0x9')]){if(_0x394e9d[_0x3210('0xa')]===_0x3210('0x8')){_0x394e9d[_0x3210('0x8')]+=0x1;updateWaitingCounter(_0x394e9d);}if(_0x394e9d['UserId']){_0x394e9d[_0x3210('0x7')]+=0x1;if(_0x394e9d[_0x3210('0x6')]){_0x394e9d['talking']-=0x1;}}else{if(_0x394e9d[_0x3210('0xa')]){_0x394e9d[_0x3210('0xb')]+=0x1;updateWaitingCounter(_0x394e9d);}}}else{if(!_0x394e9d[_0x3210('0xc')]){_0x394e9d['waiting']+=0x1;}if(_0x394e9d['UserId']){_0x394e9d[_0x3210('0x6')]+=0x1;updateWaitingCounter(_0x394e9d);}}_0x394e9d[_0x3210('0xd')]+=0x1;return _0x394e9d;}function getLastMessageText(_0x529bb5){return db[_0x3210('0xe')][_0x3210('0xf')]({'where':{'$and':[{'MailInteractionId':_0x529bb5['id']},{'$or':[{'direction':'in'},{'$and':[{'direction':_0x3210('0x10')},{'secret':![]},{'UserId':{'$ne':null}}]}]}]},'attributes':[_0x3210('0x11')],'order':_0x3210('0x12'),'raw':!![]})[_0x3210('0x13')](function(_0x573d3a){if(_0x573d3a&&_0x573d3a[_0x3210('0x11')]){_0x529bb5[_0x3210('0x14')]=_[_0x3210('0x15')](_0x573d3a[_0x3210('0x11')]);}return _0x529bb5;})[_0x3210('0x16')](function(_0x105d88){throw _0x105d88;});}exports[_0x3210('0x17')]=function(_0x28f09e,_0x4f75bb,_0xb00a2c,_0x15250c){return new Promise(function(_0x3bb39d,_0x4af274){return getInteractionUsers(_0x28f09e['id'],_0xb00a2c)[_0x3210('0x13')](function(_0x2285a3){_0x28f09e[_0x3210('0x18')]=_0x2285a3;return getInteractionTags(_0x28f09e[_0x3210('0x19')],_0x4f75bb);})[_0x3210('0x13')](function(_0x34643c){_0x28f09e[_0x3210('0x1a')]=_0x34643c;delete _0x28f09e[_0x3210('0x19')];return updateInteractionCounters(_0x28f09e);})['then'](function(_0x376c6c){if(_0x15250c){return getLastMessageText(_0x376c6c);}else{return _0x376c6c;}})['then'](function(_0xdc31e8){_0x3bb39d(_0xdc31e8);})['catch'](function(_0x560ea1){_0x4af274(_0x560ea1);});});};
\ No newline at end of file