Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / components / interaction / update-interaction.js
index c0c30cc..41385f2 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x7727=['waiting','total','closed','abandoned','UserId','talking','disposition','unmanaged','MailMessage','findOne','out','plainBody','-id','then','lastMsgText','Users','Tags','TagIds','catch','lodash','../../mysqldb','map','fullname','split','forEach','push'];(function(_0x45b47b,_0x320f20){var _0x489cb7=function(_0x4f9902){while(--_0x4f9902){_0x45b47b['push'](_0x45b47b['shift']());}};_0x489cb7(++_0x320f20);}(_0x7727,0xc9));var _0x7772=function(_0x252249,_0x51b202){_0x252249=_0x252249-0x0;var _0x1c1548=_0x7727[_0x252249];return _0x1c1548;};'use strict';var _=require(_0x7772('0x0'));var db=require(_0x7772('0x1'))['db'];function getInteractionUsers(_0x2678bf,_0x47642a){return new Promise(function(_0x90f8f9,_0x1b7fcb){try{var _0x3d50d4=[];if(_0x47642a[_0x2678bf]){_0x3d50d4=_0x47642a[_0x2678bf][_0x7772('0x2')](function(_0x479ac4){return{'id':_0x479ac4['id'],'fullname':_0x479ac4[_0x7772('0x3')]};});}return _0x90f8f9(_0x3d50d4);}catch(_0x5b3897){_0x1b7fcb(_0x5b3897);}});}function getInteractionTags(_0x1b7909,_0x5c9e17){var _0x598819=[];if(_0x1b7909){_0x1b7909[_0x7772('0x4')](',')[_0x7772('0x5')](function(_0x3ac229){_0x598819[_0x7772('0x6')](_0x5c9e17[_0x3ac229]);});}return _0x598819;}function updateWaitingCounter(_0x52ee34){if(_0x52ee34[_0x7772('0x7')]){_0x52ee34[_0x7772('0x7')]-=0x1;}}function updateInteractionCounters(_0x9324b2){_0x9324b2[_0x7772('0x7')]=0x0;_0x9324b2['talking']=0x0;_0x9324b2['answered']=0x0;_0x9324b2['unmanaged']=0x0;_0x9324b2['abandoned']=0x0;_0x9324b2[_0x7772('0x8')]=0x0;if(_0x9324b2[_0x7772('0x9')]){if(_0x9324b2['disposition']==='abandoned'){_0x9324b2[_0x7772('0xa')]+=0x1;updateWaitingCounter(_0x9324b2);}if(_0x9324b2[_0x7772('0xb')]){_0x9324b2['answered']+=0x1;if(_0x9324b2['talking']){_0x9324b2[_0x7772('0xc')]-=0x1;}}else{if(_0x9324b2[_0x7772('0xd')]){_0x9324b2[_0x7772('0xe')]+=0x1;updateWaitingCounter(_0x9324b2);}}}else{if(!_0x9324b2[_0x7772('0xb')]){_0x9324b2[_0x7772('0x7')]+=0x1;}if(_0x9324b2[_0x7772('0xb')]){_0x9324b2[_0x7772('0xc')]+=0x1;updateWaitingCounter(_0x9324b2);}}_0x9324b2[_0x7772('0x8')]+=0x1;return _0x9324b2;}function getLastMessageText(_0x222429){return db[_0x7772('0xf')][_0x7772('0x10')]({'where':{'$and':[{'MailInteractionId':_0x222429['id']},{'$or':[{'direction':'in'},{'$and':[{'direction':_0x7772('0x11')},{'secret':![]},{'UserId':{'$ne':null}}]}]}]},'attributes':[_0x7772('0x12')],'order':_0x7772('0x13'),'raw':!![]})[_0x7772('0x14')](function(_0x38085f){if(_0x38085f&&_0x38085f[_0x7772('0x12')]){_0x222429[_0x7772('0x15')]=_['trimStart'](_0x38085f[_0x7772('0x12')]);}return _0x222429;})['catch'](function(_0x5e3867){throw _0x5e3867;});}exports['updateInteraction']=function(_0x4b7562,_0x242b0b,_0x37d366,_0x453278){return new Promise(function(_0x36612f,_0x14e43b){return getInteractionUsers(_0x4b7562['id'],_0x37d366)[_0x7772('0x14')](function(_0x33bb2a){_0x4b7562[_0x7772('0x16')]=_0x33bb2a;return getInteractionTags(_0x4b7562['TagIds'],_0x242b0b);})[_0x7772('0x14')](function(_0x578e33){_0x4b7562[_0x7772('0x17')]=_0x578e33;delete _0x4b7562[_0x7772('0x18')];return updateInteractionCounters(_0x4b7562);})[_0x7772('0x14')](function(_0x29b346){if(_0x453278){return getLastMessageText(_0x29b346);}else{return _0x29b346;}})[_0x7772('0x14')](function(_0x1e4d16){_0x36612f(_0x1e4d16);})[_0x7772('0x19')](function(_0xf163ad){_0x14e43b(_0xf163ad);});});};
\ No newline at end of file
+var _0xeb91=['UserId','MailMessage','plainBody','-id','then','lastMsgText','trimStart','updateInteraction','Users','TagIds','catch','lodash','map','fullname','split','forEach','push','waiting','talking','answered','unmanaged','abandoned','total','disposition'];(function(_0x4ecd8f,_0x2aceb7){var _0x579f24=function(_0x45b431){while(--_0x45b431){_0x4ecd8f['push'](_0x4ecd8f['shift']());}};_0x579f24(++_0x2aceb7);}(_0xeb91,0x12b));var _0x1eb9=function(_0x3ca879,_0x2e88ee){_0x3ca879=_0x3ca879-0x0;var _0x1f0bae=_0xeb91[_0x3ca879];return _0x1f0bae;};'use strict';var _=require(_0x1eb9('0x0'));var db=require('../../mysqldb')['db'];function getInteractionUsers(_0x270e05,_0x405939){return new Promise(function(_0x49d851,_0x318628){try{var _0x446059=[];if(_0x405939[_0x270e05]){_0x446059=_0x405939[_0x270e05][_0x1eb9('0x1')](function(_0x2180ef){return{'id':_0x2180ef['id'],'fullname':_0x2180ef[_0x1eb9('0x2')]};});}return _0x49d851(_0x446059);}catch(_0x35d5ab){_0x318628(_0x35d5ab);}});}function getInteractionTags(_0x17dd89,_0x70de57){var _0x22da98=[];if(_0x17dd89){_0x17dd89[_0x1eb9('0x3')](',')[_0x1eb9('0x4')](function(_0x18d15c){_0x22da98[_0x1eb9('0x5')](_0x70de57[_0x18d15c]);});}return _0x22da98;}function updateWaitingCounter(_0x5da943){if(_0x5da943[_0x1eb9('0x6')]){_0x5da943[_0x1eb9('0x6')]-=0x1;}}function updateInteractionCounters(_0x5b86b6){_0x5b86b6['waiting']=0x0;_0x5b86b6[_0x1eb9('0x7')]=0x0;_0x5b86b6[_0x1eb9('0x8')]=0x0;_0x5b86b6[_0x1eb9('0x9')]=0x0;_0x5b86b6[_0x1eb9('0xa')]=0x0;_0x5b86b6[_0x1eb9('0xb')]=0x0;if(_0x5b86b6['closed']){if(_0x5b86b6[_0x1eb9('0xc')]===_0x1eb9('0xa')){_0x5b86b6[_0x1eb9('0xa')]+=0x1;updateWaitingCounter(_0x5b86b6);}if(_0x5b86b6[_0x1eb9('0xd')]){_0x5b86b6[_0x1eb9('0x8')]+=0x1;if(_0x5b86b6[_0x1eb9('0x7')]){_0x5b86b6[_0x1eb9('0x7')]-=0x1;}}else{if(_0x5b86b6[_0x1eb9('0xc')]){_0x5b86b6['unmanaged']+=0x1;updateWaitingCounter(_0x5b86b6);}}}else{if(!_0x5b86b6[_0x1eb9('0xd')]){_0x5b86b6[_0x1eb9('0x6')]+=0x1;}if(_0x5b86b6[_0x1eb9('0xd')]){_0x5b86b6[_0x1eb9('0x7')]+=0x1;updateWaitingCounter(_0x5b86b6);}}_0x5b86b6[_0x1eb9('0xb')]+=0x1;return _0x5b86b6;}function getLastMessageText(_0x363b27){return db[_0x1eb9('0xe')]['findOne']({'where':{'$and':[{'MailInteractionId':_0x363b27['id']},{'$or':[{'direction':'in'},{'$and':[{'direction':'out'},{'secret':![]},{'UserId':{'$ne':null}}]}]}]},'attributes':[_0x1eb9('0xf')],'order':_0x1eb9('0x10'),'raw':!![]})[_0x1eb9('0x11')](function(_0x1ad88d){if(_0x1ad88d&&_0x1ad88d[_0x1eb9('0xf')]){_0x363b27[_0x1eb9('0x12')]=_[_0x1eb9('0x13')](_0x1ad88d[_0x1eb9('0xf')]);}return _0x363b27;})['catch'](function(_0x5cfadf){throw _0x5cfadf;});}exports[_0x1eb9('0x14')]=function(_0x147942,_0x4f62a8,_0x421c38,_0x40e8ac){return new Promise(function(_0x2a371a,_0x130a63){return getInteractionUsers(_0x147942['id'],_0x421c38)[_0x1eb9('0x11')](function(_0x35b42f){_0x147942[_0x1eb9('0x15')]=_0x35b42f;return getInteractionTags(_0x147942[_0x1eb9('0x16')],_0x4f62a8);})[_0x1eb9('0x11')](function(_0xfcd357){_0x147942['Tags']=_0xfcd357;delete _0x147942['TagIds'];return updateInteractionCounters(_0x147942);})[_0x1eb9('0x11')](function(_0x3ca638){if(_0x40e8ac){return getLastMessageText(_0x3ca638);}else{return _0x3ca638;}})[_0x1eb9('0x11')](function(_0x421acf){_0x2a371a(_0x421acf);})[_0x1eb9('0x17')](function(_0xe6f3f){_0x130a63(_0xe6f3f);});});};
\ No newline at end of file