Built motion from commit 00bf23f6.|2.6.16
[motion2.git] / server / components / interaction / service.js
index 6cfb507..38291fe 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xfc66=['../../config/logger','sms-interactions','chat-interactions','whatsapp-interactions','InteractionId','upperFirst','name','role','stringify','null','Interaction','findOne','then','info','error','tracked','user','query','clone','body','html','fax','mobile','lodash','../../mysqldb','openchannel-interactions','mail-interactions'];(function(_0x6ec16,_0x2e8212){var _0x2b62ac=function(_0x3aa462){while(--_0x3aa462){_0x6ec16['push'](_0x6ec16['shift']());}};_0x2b62ac(++_0x2e8212);}(_0xfc66,0x140));var _0x6fc6=function(_0x1174ca,_0x4964c3){_0x1174ca=_0x1174ca-0x0;var _0x3570c7=_0xfc66[_0x1174ca];return _0x3570c7;};'use strict';var _=require(_0x6fc6('0x0'));var db=require(_0x6fc6('0x1'))['db'];var loggers={'openchannel':require('../../config/logger')(_0x6fc6('0x2')),'mail':require('../../config/logger')(_0x6fc6('0x3')),'fax':require('../../config/logger')('fax-interactions'),'sms':require(_0x6fc6('0x4'))(_0x6fc6('0x5')),'chat':require('../../config/logger')(_0x6fc6('0x6')),'whatsapp':require(_0x6fc6('0x4'))(_0x6fc6('0x7'))};function getInteractionId(_0xcc210a,_0x261e13,_0x421bb7){if(_0xcc210a&&_0xcc210a[_['upperFirst'](_0x421bb7)+_0x6fc6('0x8')]){return _0xcc210a[_[_0x6fc6('0x9')](_0x421bb7)+_0x6fc6('0x8')];}else if(_0xcc210a&&_0xcc210a['id']){return _0xcc210a['id'];}else if(_0x261e13&&_0x261e13['id']){return _0x261e13['id'];}else{return'unknown';}}function log(_0xd7e97e,_0x3b0fa0,_0x1acbe0,_0x23c4eb,_0x35401a,_0x5bf191){loggers[_0x35401a['toLowerCase']()][_0xd7e97e]('[%s]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0x5bf191['toUpperCase'](),_0x3b0fa0?_0x3b0fa0['id']:null,_0x3b0fa0?_0x3b0fa0[_0x6fc6('0xa')]:null,_0x3b0fa0?_0x3b0fa0[_0x6fc6('0xb')]:null,getInteractionId(_0x1acbe0,_0x23c4eb,_0x35401a),_0x1acbe0?JSON[_0x6fc6('0xc')](_0x1acbe0):_0x6fc6('0xd'));}function updateUser(_0x3ed30b,_0x5f5bdc,_0x36bb8f,_0x2e339d,_0x3af1c7){db[_[_0x6fc6('0x9')](_0x2e339d)+_0x6fc6('0xe')][_0x6fc6('0xf')]({'where':{'id':getInteractionId(_0x5f5bdc,_0x36bb8f,_0x2e339d)}})[_0x6fc6('0x10')](function(_0x123bd8){if(_0x123bd8){return _0x123bd8['update']({'UserId':_0x3ed30b?_0x3ed30b['id']:null});}})[_0x6fc6('0x10')](function(_0x2c0772){if(_0x2c0772){log(_0x6fc6('0x11'),_0x3ed30b,_0x5f5bdc,_0x36bb8f,_0x2e339d,_0x3af1c7);}})['catch'](function(){log(_0x6fc6('0x12'),_0x3ed30b,_0x5f5bdc,_0x36bb8f,_0x2e339d,_0x3af1c7);});}exports[_0x6fc6('0x13')]=function(_0x129ce7,_0x504763){return function(_0x2125c0,_0xa80c14,_0x3f1ade){var _0x4f7bb1=_0x2125c0[_0x6fc6('0x14')];var _0x37674a={};var _0x3cf742=_0x2125c0[_0x6fc6('0x15')];if(_0x37674a){_0x37674a=_[_0x6fc6('0x16')](_0x2125c0[_0x6fc6('0x17')]);_0x37674a=_['omit'](_0x37674a,['body',_0x6fc6('0x18'),'phone',_0x6fc6('0x19'),_0x6fc6('0x1a')]);}updateUser(_0x4f7bb1,_0x37674a,_0x3cf742,_0x129ce7,_0x504763);_0x3f1ade(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