Built motion from commit bab6f49e.|2.6.17
[motion2.git] / server / api / cmContact / cmContact.rpc.js
index a570426..96123d2 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6382=['socket.io-emitter','./cmContact.socket','request','info','CmContact,\x20%s,\x20%s','debug','request\x20sent','stringify','error','code','message','result','GetCmContact','CmContact','options','raw','where','attributes','limit','map','include','catch','create','body','then','keys','length','startsWith','update','table','cm_contacts','set','id\x20=\x20?','toString','sequelize','query','CreateCmContact','util','moment','bluebird','randomstring','ioredis','squel','../../config/utils','rpc','../../config/environment','client','http','redis'];(function(_0x490ef3,_0x15ae09){var _0x4f9dc0=function(_0x559420){while(--_0x559420){_0x490ef3['push'](_0x490ef3['shift']());}};_0x4f9dc0(++_0x15ae09);}(_0x6382,0x14b));var _0x2638=function(_0x1ee627,_0x23a5d4){_0x1ee627=_0x1ee627-0x0;var _0x2f7649=_0x6382[_0x1ee627];return _0x2f7649;};'use strict';var _=require('lodash');var util=require(_0x2638('0x0'));var moment=require(_0x2638('0x1'));var BPromise=require(_0x2638('0x2'));var rs=require(_0x2638('0x3'));var fs=require('fs');var Redis=require(_0x2638('0x4'));var squel=require(_0x2638('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0x2638('0x6'));var logger=require('../../config/logger')(_0x2638('0x7'));var config=require(_0x2638('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x2638('0x9')][_0x2638('0xa')]({'port':0x232a});config[_0x2638('0xb')]=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x2638('0xc'))(new Redis(config[_0x2638('0xb')]));require(_0x2638('0xd'))['register'](socket);function respondWithRpcPromise(_0x5208ce,_0x4e33b8,_0x399ab4){return new BPromise(function(_0x3758cf,_0x485512){return client[_0x2638('0xe')](_0x5208ce,_0x399ab4)['then'](function(_0x48d090){logger[_0x2638('0xf')](_0x2638('0x10'),_0x4e33b8,'request\x20sent');logger[_0x2638('0x11')]('CmContact,\x20%s,\x20%s,\x20%s',_0x4e33b8,_0x2638('0x12'),JSON[_0x2638('0x13')](_0x48d090));if(_0x48d090[_0x2638('0x14')]){if(_0x48d090[_0x2638('0x14')][_0x2638('0x15')]===0x1f4){logger[_0x2638('0x14')](_0x2638('0x10'),_0x4e33b8,_0x48d090[_0x2638('0x14')]['message']);return _0x485512(_0x48d090[_0x2638('0x14')][_0x2638('0x16')]);}logger['error'](_0x2638('0x10'),_0x4e33b8,_0x48d090[_0x2638('0x14')][_0x2638('0x16')]);return _0x3758cf(_0x48d090[_0x2638('0x14')][_0x2638('0x16')]);}else{logger[_0x2638('0xf')](_0x2638('0x10'),_0x4e33b8,_0x2638('0x12'));_0x3758cf(_0x48d090[_0x2638('0x17')][_0x2638('0x16')]);}})['catch'](function(_0x13e2c9){logger[_0x2638('0x14')](_0x2638('0x10'),_0x4e33b8,_0x13e2c9);_0x485512(_0x13e2c9);});});}exports[_0x2638('0x18')]=function(_0x275339){var _0x431bf2=this;return new Promise(function(_0x2c9776,_0xfbdc7d){return db[_0x2638('0x19')]['findAll']({'raw':_0x275339[_0x2638('0x1a')]?_0x275339[_0x2638('0x1a')][_0x2638('0x1b')]===undefined?!![]:![]:!![],'where':_0x275339[_0x2638('0x1a')]?_0x275339[_0x2638('0x1a')][_0x2638('0x1c')]||null:null,'attributes':_0x275339[_0x2638('0x1a')]?_0x275339['options'][_0x2638('0x1d')]||null:null,'limit':_0x275339['options']?_0x275339[_0x2638('0x1a')][_0x2638('0x1e')]||null:null,'include':_0x275339['options']?_0x275339['options']['include']?_[_0x2638('0x1f')](_0x275339[_0x2638('0x1a')][_0x2638('0x20')],function(_0x4593ff){return{'model':db[_0x4593ff['model']],'as':_0x4593ff['as'],'attributes':_0x4593ff[_0x2638('0x1d')],'include':_0x4593ff[_0x2638('0x20')]?_[_0x2638('0x1f')](_0x4593ff[_0x2638('0x20')],function(_0x15cf65){return{'model':db[_0x15cf65['model']],'as':_0x15cf65['as'],'attributes':_0x15cf65[_0x2638('0x1d')],'include':_0x15cf65[_0x2638('0x20')]?_[_0x2638('0x1f')](_0x15cf65[_0x2638('0x20')],function(_0x551820){return{'model':db[_0x551820['model']],'as':_0x551820['as'],'attributes':_0x551820[_0x2638('0x1d')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x228904){logger['info'](_0x2638('0x18'),_0x275339);logger[_0x2638('0x11')]('GetCmContact',_0x275339,JSON['stringify'](_0x228904));_0x2c9776(_0x228904);})[_0x2638('0x21')](function(_0x160eb9){logger[_0x2638('0x14')](_0x2638('0x18'),_0x160eb9[_0x2638('0x16')],_0x275339);_0xfbdc7d(_0x431bf2[_0x2638('0x14')](0x1f4,_0x160eb9[_0x2638('0x16')]));});});};exports['CreateCmContact']=function(_0x48110c){var _0x1390d1=this;return new Promise(function(_0x2b352a,_0xf1473c){return db['CmContact'][_0x2638('0x22')](_0x48110c[_0x2638('0x23')],{'raw':_0x48110c[_0x2638('0x1a')]?_0x48110c[_0x2638('0x1a')]['raw']===undefined?!![]:![]:!![]})[_0x2638('0x24')](function(_0x5372f6){var _0xe372e7;for(var _0x13bdb3=0x0;_0x13bdb3<Object[_0x2638('0x25')](_0x48110c['body'])[_0x2638('0x26')];_0x13bdb3++){var _0x497ff5=Object[_0x2638('0x25')](_0x48110c[_0x2638('0x23')])[_0x13bdb3];if(_0x497ff5[_0x2638('0x27')]('cf_')){_0xe372e7=squel[_0x2638('0x28')]()[_0x2638('0x29')](_0x2638('0x2a'))[_0x2638('0x2b')](_0x497ff5,_0x48110c[_0x2638('0x23')][_0x497ff5])[_0x2638('0x1c')](_0x2638('0x2c'),_0x5372f6['id'])[_0x2638('0x2d')]();break;}}if(!_0xe372e7)return _0x5372f6;return db[_0x2638('0x2e')][_0x2638('0x2f')](_0xe372e7)['then'](function(){return _0x5372f6;});})[_0x2638('0x24')](function(_0x1cace8){logger[_0x2638('0xf')](_0x2638('0x30'),_0x48110c);logger[_0x2638('0x11')](_0x2638('0x30'),_0x48110c,JSON['stringify'](_0x1cace8));_0x2b352a(_0x1cace8);})[_0x2638('0x21')](function(_0x32b372){logger[_0x2638('0x14')](_0x2638('0x30'),_0x32b372[_0x2638('0x16')],_0x48110c);_0xf1473c(_0x1390d1[_0x2638('0x14')](0x1f4,_0x32b372[_0x2638('0x16')]));});});};
\ No newline at end of file
+var _0xa9e0=['phone','ListId','Contact','CmContactId','create','body','keys','length','startsWith','update','table','cm_contacts','id\x20=\x20?','sequelize','query','CreateCmContact','lodash','util','moment','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','redis','localhost','./cmContact.socket','register','info','CmContact,\x20%s,\x20%s','request\x20sent','debug','CmContact,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','GetCmContact','CmContact','findAll','options','where','limit','include','map','model','attributes','then','stringify','CmContactHasItem','find'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xa9e0,0x123));var _0x0a9e=function(_0x2dafbe,_0x5d04de){_0x2dafbe=_0x2dafbe-0x0;var _0x58a45a=_0xa9e0[_0x2dafbe];return _0x58a45a;};'use strict';var _=require(_0x0a9e('0x0'));var util=require(_0x0a9e('0x1'));var moment=require(_0x0a9e('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x0a9e('0x3'));var squel=require('squel');var db=require(_0x0a9e('0x4'))['db'];var utils=require(_0x0a9e('0x5'));var logger=require(_0x0a9e('0x6'))(_0x0a9e('0x7'));var config=require(_0x0a9e('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x0a9e('0x9')][_0x0a9e('0xa')]({'port':0x232a});config[_0x0a9e('0xb')]=_['defaults'](config['redis'],{'host':_0x0a9e('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x0a9e('0xd'))[_0x0a9e('0xe')](socket);function respondWithRpcPromise(_0x307b3e,_0x3ab53f,_0xfeb75b){return new BPromise(function(_0xbd1168,_0x4a4c56){return client['request'](_0x307b3e,_0xfeb75b)['then'](function(_0x4cfe67){logger[_0x0a9e('0xf')](_0x0a9e('0x10'),_0x3ab53f,_0x0a9e('0x11'));logger[_0x0a9e('0x12')](_0x0a9e('0x13'),_0x3ab53f,_0x0a9e('0x11'),JSON['stringify'](_0x4cfe67));if(_0x4cfe67[_0x0a9e('0x14')]){if(_0x4cfe67[_0x0a9e('0x14')][_0x0a9e('0x15')]===0x1f4){logger[_0x0a9e('0x14')](_0x0a9e('0x10'),_0x3ab53f,_0x4cfe67[_0x0a9e('0x14')]['message']);return _0x4a4c56(_0x4cfe67[_0x0a9e('0x14')]['message']);}logger[_0x0a9e('0x14')]('CmContact,\x20%s,\x20%s',_0x3ab53f,_0x4cfe67[_0x0a9e('0x14')][_0x0a9e('0x16')]);return _0xbd1168(_0x4cfe67['error'][_0x0a9e('0x16')]);}else{logger['info'](_0x0a9e('0x10'),_0x3ab53f,_0x0a9e('0x11'));_0xbd1168(_0x4cfe67[_0x0a9e('0x17')][_0x0a9e('0x16')]);}})[_0x0a9e('0x18')](function(_0x2eb11f){logger[_0x0a9e('0x14')](_0x0a9e('0x10'),_0x3ab53f,_0x2eb11f);_0x4a4c56(_0x2eb11f);});});}exports[_0x0a9e('0x19')]=function(_0x112016){var _0x1c696a=this;return new Promise(function(_0x105080,_0x4bb1e3){return db[_0x0a9e('0x1a')][_0x0a9e('0x1b')]({'raw':_0x112016['options']?_0x112016[_0x0a9e('0x1c')]['raw']===undefined?!![]:![]:!![],'where':_0x112016['options']?_0x112016[_0x0a9e('0x1c')][_0x0a9e('0x1d')]||null:null,'attributes':_0x112016[_0x0a9e('0x1c')]?_0x112016[_0x0a9e('0x1c')]['attributes']||null:null,'limit':_0x112016[_0x0a9e('0x1c')]?_0x112016[_0x0a9e('0x1c')][_0x0a9e('0x1e')]||null:null,'include':_0x112016[_0x0a9e('0x1c')]?_0x112016[_0x0a9e('0x1c')][_0x0a9e('0x1f')]?_[_0x0a9e('0x20')](_0x112016['options']['include'],function(_0x197ec0){return{'model':db[_0x197ec0[_0x0a9e('0x21')]],'as':_0x197ec0['as'],'attributes':_0x197ec0[_0x0a9e('0x22')],'include':_0x197ec0[_0x0a9e('0x1f')]?_['map'](_0x197ec0[_0x0a9e('0x1f')],function(_0x479bc4){return{'model':db[_0x479bc4[_0x0a9e('0x21')]],'as':_0x479bc4['as'],'attributes':_0x479bc4['attributes'],'include':_0x479bc4[_0x0a9e('0x1f')]?_[_0x0a9e('0x20')](_0x479bc4[_0x0a9e('0x1f')],function(_0x14433c){return{'model':db[_0x14433c[_0x0a9e('0x21')]],'as':_0x14433c['as'],'attributes':_0x14433c[_0x0a9e('0x22')]};}):[]};}):[]};}):[]:[]})[_0x0a9e('0x23')](function(_0x14de77){logger['info'](_0x0a9e('0x19'),_0x112016);logger[_0x0a9e('0x12')](_0x0a9e('0x19'),_0x112016,JSON[_0x0a9e('0x24')](_0x14de77));if(_0x14de77['length']==0x0){return db[_0x0a9e('0x25')][_0x0a9e('0x26')]({'raw':!![],'where':{'item':_0x112016[_0x0a9e('0x1c')][_0x0a9e('0x27')]},'include':[{'model':db[_0x0a9e('0x1a')],'where':{'ListId':_0x112016[_0x0a9e('0x1c')][_0x0a9e('0x1d')][_0x0a9e('0x28')],'deletedAt':{'$eq':null}},'as':_0x0a9e('0x29')}]})['then'](function(_0x426950){if(_['isNil'](_0x426950)){_0x105080(_0x14de77);}else{var _0x2407f9=_0x426950[_0x0a9e('0x2a')];return db[_0x0a9e('0x1a')][_0x0a9e('0x1b')]({'raw':!![],'where':{'id':_0x2407f9},'attributes':_0x112016[_0x0a9e('0x1c')]?_0x112016['options'][_0x0a9e('0x22')]||null:null})[_0x0a9e('0x23')](function(_0x40cb85){_0x105080(_0x40cb85);});}});}else{_0x105080(_0x14de77);}})[_0x0a9e('0x18')](function(_0x2b45ea){logger[_0x0a9e('0x14')](_0x0a9e('0x19'),_0x2b45ea[_0x0a9e('0x16')],_0x112016);_0x4bb1e3(_0x1c696a['error'](0x1f4,_0x2b45ea[_0x0a9e('0x16')]));});});};exports['CreateCmContact']=function(_0x2cc7a0){var _0x14b13f=this;return new Promise(function(_0x2b7e7f,_0x3f3d41){return db['CmContact'][_0x0a9e('0x2b')](_0x2cc7a0[_0x0a9e('0x2c')],{'raw':_0x2cc7a0[_0x0a9e('0x1c')]?_0x2cc7a0[_0x0a9e('0x1c')]['raw']===undefined?!![]:![]:!![]})['then'](function(_0x1e8694){var _0x5640eb;for(var _0x24936a=0x0;_0x24936a<Object[_0x0a9e('0x2d')](_0x2cc7a0[_0x0a9e('0x2c')])[_0x0a9e('0x2e')];_0x24936a++){var _0x4f41ae=Object[_0x0a9e('0x2d')](_0x2cc7a0[_0x0a9e('0x2c')])[_0x24936a];if(_0x4f41ae[_0x0a9e('0x2f')]('cf_')){_0x5640eb=squel[_0x0a9e('0x30')]()[_0x0a9e('0x31')](_0x0a9e('0x32'))['set'](_0x4f41ae,_0x2cc7a0['body'][_0x4f41ae])[_0x0a9e('0x1d')](_0x0a9e('0x33'),_0x1e8694['id'])['toString']();break;}}if(!_0x5640eb)return _0x1e8694;return db[_0x0a9e('0x34')][_0x0a9e('0x35')](_0x5640eb)[_0x0a9e('0x23')](function(){return _0x1e8694;});})[_0x0a9e('0x23')](function(_0x4b38d9){logger['info'](_0x0a9e('0x36'),_0x2cc7a0);logger[_0x0a9e('0x12')]('CreateCmContact',_0x2cc7a0,JSON[_0x0a9e('0x24')](_0x4b38d9));_0x2b7e7f(_0x4b38d9);})[_0x0a9e('0x18')](function(_0x1459bb){logger['error'](_0x0a9e('0x36'),_0x1459bb[_0x0a9e('0x16')],_0x2cc7a0);_0x3f3d41(_0x14b13f[_0x0a9e('0x14')](0x1f4,_0x1459bb[_0x0a9e('0x16')]));});});};
\ No newline at end of file