Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / components / interaction / update-interaction.js
index c0c30cc..44780e0 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 _0x817b=['MailMessage','findOne','out','plainBody','then','lastMsgText','trimStart','catch','updateInteraction','Users','TagIds','Tags','../../mysqldb','map','fullname','forEach','waiting','talking','answered','unmanaged','closed','disposition','abandoned','UserId','total'];(function(_0x52961c,_0x1c7d2f){var _0x47176c=function(_0x40ca6b){while(--_0x40ca6b){_0x52961c['push'](_0x52961c['shift']());}};_0x47176c(++_0x1c7d2f);}(_0x817b,0x89));var _0xb817=function(_0x4ba730,_0x368687){_0x4ba730=_0x4ba730-0x0;var _0x49c90b=_0x817b[_0x4ba730];return _0x49c90b;};'use strict';var _=require('lodash');var db=require(_0xb817('0x0'))['db'];function getInteractionUsers(_0x40fd8a,_0x27c742){return new Promise(function(_0x58097a,_0x1a2cae){try{var _0x5900d2=[];if(_0x27c742[_0x40fd8a]){_0x5900d2=_0x27c742[_0x40fd8a][_0xb817('0x1')](function(_0x2d7185){return{'id':_0x2d7185['id'],'fullname':_0x2d7185[_0xb817('0x2')]};});}return _0x58097a(_0x5900d2);}catch(_0x557f9d){_0x1a2cae(_0x557f9d);}});}function getInteractionTags(_0x5565e2,_0x5b7dc0){var _0x2286f9=[];if(_0x5565e2){_0x5565e2['split'](',')[_0xb817('0x3')](function(_0x1a15e2){_0x2286f9['push'](_0x5b7dc0[_0x1a15e2]);});}return _0x2286f9;}function updateWaitingCounter(_0x4c8449){if(_0x4c8449[_0xb817('0x4')]){_0x4c8449[_0xb817('0x4')]-=0x1;}}function updateInteractionCounters(_0x204d67){_0x204d67[_0xb817('0x4')]=0x0;_0x204d67[_0xb817('0x5')]=0x0;_0x204d67[_0xb817('0x6')]=0x0;_0x204d67[_0xb817('0x7')]=0x0;_0x204d67['abandoned']=0x0;_0x204d67['total']=0x0;if(_0x204d67[_0xb817('0x8')]){if(_0x204d67[_0xb817('0x9')]===_0xb817('0xa')){_0x204d67[_0xb817('0xa')]+=0x1;updateWaitingCounter(_0x204d67);}if(_0x204d67[_0xb817('0xb')]){_0x204d67['answered']+=0x1;if(_0x204d67[_0xb817('0x5')]){_0x204d67[_0xb817('0x5')]-=0x1;}}else{if(_0x204d67[_0xb817('0x9')]){_0x204d67['unmanaged']+=0x1;updateWaitingCounter(_0x204d67);}}}else{if(!_0x204d67[_0xb817('0xb')]){_0x204d67[_0xb817('0x4')]+=0x1;}if(_0x204d67[_0xb817('0xb')]){_0x204d67[_0xb817('0x5')]+=0x1;updateWaitingCounter(_0x204d67);}}_0x204d67[_0xb817('0xc')]+=0x1;return _0x204d67;}function getLastMessageText(_0x20f332){return db[_0xb817('0xd')][_0xb817('0xe')]({'where':{'$and':[{'MailInteractionId':_0x20f332['id']},{'$or':[{'direction':'in'},{'$and':[{'direction':_0xb817('0xf')},{'secret':![]},{'UserId':{'$ne':null}}]}]}]},'attributes':[_0xb817('0x10')],'order':'-id','raw':!![]})[_0xb817('0x11')](function(_0x5b795c){if(_0x5b795c&&_0x5b795c[_0xb817('0x10')]){_0x20f332[_0xb817('0x12')]=_[_0xb817('0x13')](_0x5b795c[_0xb817('0x10')]);}return _0x20f332;})[_0xb817('0x14')](function(_0x1c10da){throw _0x1c10da;});}exports[_0xb817('0x15')]=function(_0x509832,_0x471fc1,_0x1298f2,_0xf13cf2){return new Promise(function(_0xd38ff8,_0x5758d8){return getInteractionUsers(_0x509832['id'],_0x1298f2)[_0xb817('0x11')](function(_0x4eec17){_0x509832[_0xb817('0x16')]=_0x4eec17;return getInteractionTags(_0x509832[_0xb817('0x17')],_0x471fc1);})['then'](function(_0x49d12d){_0x509832[_0xb817('0x18')]=_0x49d12d;delete _0x509832['TagIds'];return updateInteractionCounters(_0x509832);})[_0xb817('0x11')](function(_0x3a8180){if(_0xf13cf2){return getLastMessageText(_0x3a8180);}else{return _0x3a8180;}})[_0xb817('0x11')](function(_0x524039){_0xd38ff8(_0x524039);})[_0xb817('0x14')](function(_0x383ad4){_0x5758d8(_0x383ad4);});});};
\ No newline at end of file