Built motion from commit 00bf23f6.|2.6.16
[motion2.git] / server / components / interaction / service.js
index 1e8bde1..38291fe 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x1e9d=['html','mobile','lodash','../../config/logger','openchannel-interactions','mail-interactions','InteractionId','unknown','toLowerCase','[%s]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','toUpperCase','role','stringify','null','upperFirst','Interaction','update','info','catch','error','tracked','user','query','body','omit'];(function(_0x3fa631,_0x24392c){var _0x5c9dec=function(_0x36d01a){while(--_0x36d01a){_0x3fa631['push'](_0x3fa631['shift']());}};_0x5c9dec(++_0x24392c);}(_0x1e9d,0x1dd));var _0xd1e9=function(_0x5be002,_0x32a760){_0x5be002=_0x5be002-0x0;var _0x313edf=_0x1e9d[_0x5be002];return _0x313edf;};'use strict';var _=require(_0xd1e9('0x0'));var db=require('../../mysqldb')['db'];var loggers={'openchannel':require(_0xd1e9('0x1'))(_0xd1e9('0x2')),'mail':require(_0xd1e9('0x1'))(_0xd1e9('0x3')),'fax':require(_0xd1e9('0x1'))('fax-interactions'),'sms':require(_0xd1e9('0x1'))('sms-interactions'),'chat':require('../../config/logger')('chat-interactions'),'whatsapp':require('../../config/logger')('whatsapp-interactions')};function getInteractionId(_0x15061,_0x3dea6,_0x3a9acc){if(_0x15061&&_0x15061[_['upperFirst'](_0x3a9acc)+_0xd1e9('0x4')]){return _0x15061[_['upperFirst'](_0x3a9acc)+_0xd1e9('0x4')];}else if(_0x15061&&_0x15061['id']){return _0x15061['id'];}else if(_0x3dea6&&_0x3dea6['id']){return _0x3dea6['id'];}else{return _0xd1e9('0x5');}}function log(_0x264a37,_0x3f9e20,_0x431041,_0xd32c3a,_0x2ca5fd,_0x1cbb6c){loggers[_0x2ca5fd[_0xd1e9('0x6')]()][_0x264a37](_0xd1e9('0x7'),_0x1cbb6c[_0xd1e9('0x8')](),_0x3f9e20?_0x3f9e20['id']:null,_0x3f9e20?_0x3f9e20['name']:null,_0x3f9e20?_0x3f9e20[_0xd1e9('0x9')]:null,getInteractionId(_0x431041,_0xd32c3a,_0x2ca5fd),_0x431041?JSON[_0xd1e9('0xa')](_0x431041):_0xd1e9('0xb'));}function updateUser(_0x35e0d8,_0x493b7e,_0x54284d,_0xebbfd2,_0x4bac7e){db[_[_0xd1e9('0xc')](_0xebbfd2)+_0xd1e9('0xd')]['findOne']({'where':{'id':getInteractionId(_0x493b7e,_0x54284d,_0xebbfd2)}})['then'](function(_0x4e397e){if(_0x4e397e){return _0x4e397e[_0xd1e9('0xe')]({'UserId':_0x35e0d8?_0x35e0d8['id']:null});}})['then'](function(_0x3923c2){if(_0x3923c2){log(_0xd1e9('0xf'),_0x35e0d8,_0x493b7e,_0x54284d,_0xebbfd2,_0x4bac7e);}})[_0xd1e9('0x10')](function(){log(_0xd1e9('0x11'),_0x35e0d8,_0x493b7e,_0x54284d,_0xebbfd2,_0x4bac7e);});}exports[_0xd1e9('0x12')]=function(_0xae9af1,_0x3fab17){return function(_0xcf2d85,_0x4d4b4b,_0x559512){var _0xd87512=_0xcf2d85[_0xd1e9('0x13')];var _0x3ac9b5={};var _0x37c07e=_0xcf2d85[_0xd1e9('0x14')];if(_0x3ac9b5){_0x3ac9b5=_['clone'](_0xcf2d85[_0xd1e9('0x15')]);_0x3ac9b5=_[_0xd1e9('0x16')](_0x3ac9b5,['body',_0xd1e9('0x17'),'phone','fax',_0xd1e9('0x18')]);}updateUser(_0xd87512,_0x3ac9b5,_0x37c07e,_0xae9af1,_0x3fab17);_0x559512(null);};};
\ No newline at end of file
+var _0x1f62=['i.id','ids','tag','count','clause','order','forEach','DESC','closed','getFilteredInteractions','catch','query','omit','html','fax','mobile','updateUser','./sql-utils','findAll','resolve','then','search','parseAdvancedSearchFilter','parseQueryParameters','body','where','contact','default','fields','filter','user','having','read','tags','checkAccountsRestrictions','group'];(function(_0x34021d,_0x753aa6){var _0x16597b=function(_0x2d040a){while(--_0x2d040a){_0x34021d['push'](_0x34021d['shift']());}};_0x16597b(++_0x753aa6);}(_0x1f62,0x1c1));var _0x21f6=function(_0x32c98a,_0x5e6eb0){_0x32c98a=_0x32c98a-0x0;var _0x1796d3=_0x1f62[_0x32c98a];return _0x1796d3;};'use strict';var _=require('lodash');var sqlUtils=require(_0x21f6('0x0'));var utils=require('./utils');exports[_0x21f6('0x1')]=function(_0x50593e,_0x156436,_0x4de686,_0x1cbd95,_0x27ed5f){var _0x3fe8b5={'count':0x0,'rows':[]};var _0x17a23b=sqlUtils['skipInteractionsQuery'](_0x50593e,_0x4de686,_0x156436);if(_0x17a23b){return Promise[_0x21f6('0x2')](_0x3fe8b5);}var _0x42dba0=sqlUtils['getInteractionsQuery'](_0x50593e);var _0x32713e={};return Promise['resolve']()[_0x21f6('0x3')](function(){if(_0x156436[_0x21f6('0x4')]){return sqlUtils[_0x21f6('0x5')](_0x156436[_0x21f6('0x4')],_0x27ed5f);}else{return sqlUtils[_0x21f6('0x6')](_0x50593e,_0x156436,_0x27ed5f);}})['then'](function(_0x1f6c9f){_0x42dba0['where'](_0x1f6c9f[_0x21f6('0x7')]);_0x42dba0[_0x21f6('0x8')](_0x1f6c9f[_0x21f6('0x9')]);_0x42dba0['where'](_0x1f6c9f[_0x21f6('0xa')]);_0x42dba0[_0x21f6('0x8')](_0x1f6c9f[_0x21f6('0xb')]);_0x42dba0['where'](_0x1f6c9f[_0x21f6('0xc')]);_0x42dba0[_0x21f6('0x8')](_0x1f6c9f[_0x21f6('0xd')]);_0x42dba0[_0x21f6('0xe')](_0x1f6c9f[_0x21f6('0xf')]);_0x32713e=_0x1f6c9f[_0x21f6('0x10')];return sqlUtils[_0x21f6('0x11')](_0x50593e,_0x4de686,_0x156436);})[_0x21f6('0x3')](function(_0x36de4a){_0x42dba0[_0x21f6('0x8')](_0x36de4a);_0x42dba0[_0x21f6('0x12')](_0x21f6('0x13'));var _0x445cd2=_0x156436['search']?_0x32713e[_0x21f6('0x14')]:_0x156436[_0x21f6('0x15')];return sqlUtils['countFilteredInteractions'](_0x42dba0,_0x445cd2);})['then'](function(_0x1dba6b){_0x3fe8b5[_0x21f6('0x16')]=_0x1dba6b['length'];if(_0x3fe8b5['count']===0x0){return[];}_0x42dba0[_0x21f6('0xe')](_0x32713e[_0x21f6('0x17')]);if(_0x1cbd95[_0x21f6('0x18')]){_0x1cbd95[_0x21f6('0x18')][_0x21f6('0x19')](function(_0x26a51e){var _0x11d619=_0x26a51e[0x0]==='contactName'?_0x26a51e[0x0]:'i.'+_0x26a51e[0x0];_0x42dba0[_0x21f6('0x18')](_0x11d619,_0x26a51e[0x1]===_0x21f6('0x1a')?![]:!![]);if(_0x26a51e[0x0]===_0x21f6('0x1b')){var _0x4616df=sqlUtils['getClosedOrderClause'](_0x50593e,_0x156436);_0x42dba0[_0x21f6('0x18')](_0x4616df,_0x26a51e[0x1]===_0x21f6('0x1a')?![]:!![]);}});}return sqlUtils[_0x21f6('0x1c')](_0x50593e,_0x42dba0,_0x156436,_0x1cbd95);})['then'](function(_0x569b31){_0x3fe8b5['rows']=_0x569b31;return _0x3fe8b5;})[_0x21f6('0x1d')](function(_0x2ba551){throw _0x2ba551;});};exports['tracked']=function(_0x559fd6,_0x5b04b1){return function(_0x398b43,_0x272a38,_0x4c0ec6){var _0x223179=_0x398b43[_0x21f6('0xd')];var _0x52ca8f={};var _0x5025e6=_0x398b43[_0x21f6('0x1e')];if(_0x52ca8f){_0x52ca8f=_['clone'](_0x398b43[_0x21f6('0x7')]);_0x52ca8f=_[_0x21f6('0x1f')](_0x52ca8f,[_0x21f6('0x7'),_0x21f6('0x20'),'phone',_0x21f6('0x21'),_0x21f6('0x22')]);}utils[_0x21f6('0x23')](_0x223179,_0x52ca8f,_0x5025e6,_0x559fd6,_0x5b04b1);_0x4c0ec6(null);};};
\ No newline at end of file