Built motion from commit (unavailable).|2.4.17
[motion2.git] / server / api / cmContact / cmContact.rpc.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x729f=['info','result','catch','CmContact','find','options','raw','include','map','model','attributes','ShowCmContact','CreateCmContact','create','lodash','util','moment','bluebird','ioredis','../../mysqldb','rpc','../../config/environment','jayson/promise','client','redis','defaults','localhost','socket.io-emitter','./cmContact.socket','register','request','CmContact,\x20%s,\x20%s','request\x20sent','debug','CmContact,\x20%s,\x20%s,\x20%s','stringify','error','code','message'];(function(_0x4e2272,_0x2e1ae0){var _0x45511c=function(_0x285414){while(--_0x285414){_0x4e2272['push'](_0x4e2272['shift']());}};_0x45511c(++_0x2e1ae0);}(_0x729f,0x1bb));var _0xf729=function(_0x34ce11,_0x3248de){_0x34ce11=_0x34ce11-0x0;var _0x3b08a2=_0x729f[_0x34ce11];return _0x3b08a2;};'use strict';var _=require(_0xf729('0x0'));var util=require(_0xf729('0x1'));var moment=require(_0xf729('0x2'));var BPromise=require(_0xf729('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xf729('0x4'));var db=require(_0xf729('0x5'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0xf729('0x6'));var config=require(_0xf729('0x7'));var jayson=require(_0xf729('0x8'));var client=jayson[_0xf729('0x9')]['http']({'port':0x232a});config[_0xf729('0xa')]=_[_0xf729('0xb')](config['redis'],{'host':_0xf729('0xc'),'port':0x18eb});var socket=require(_0xf729('0xd'))(new Redis(config['redis']));require(_0xf729('0xe'))[_0xf729('0xf')](socket);function respondWithRpcPromise(_0x9059cb,_0x5e9b41,_0xa1ad96){return new BPromise(function(_0x358efc,_0x534be7){return client[_0xf729('0x10')](_0x9059cb,_0xa1ad96)['then'](function(_0x17b6cd){logger['info'](_0xf729('0x11'),_0x5e9b41,_0xf729('0x12'));logger[_0xf729('0x13')](_0xf729('0x14'),_0x5e9b41,_0xf729('0x12'),JSON[_0xf729('0x15')](_0x17b6cd));if(_0x17b6cd[_0xf729('0x16')]){if(_0x17b6cd[_0xf729('0x16')][_0xf729('0x17')]===0x1f4){logger[_0xf729('0x16')]('CmContact,\x20%s,\x20%s',_0x5e9b41,_0x17b6cd[_0xf729('0x16')][_0xf729('0x18')]);return _0x534be7(_0x17b6cd[_0xf729('0x16')][_0xf729('0x18')]);}logger[_0xf729('0x16')](_0xf729('0x11'),_0x5e9b41,_0x17b6cd[_0xf729('0x16')][_0xf729('0x18')]);return _0x358efc(_0x17b6cd[_0xf729('0x16')][_0xf729('0x18')]);}else{logger[_0xf729('0x19')](_0xf729('0x11'),_0x5e9b41,'request\x20sent');_0x358efc(_0x17b6cd[_0xf729('0x1a')][_0xf729('0x18')]);}})[_0xf729('0x1b')](function(_0x2453b0){logger[_0xf729('0x16')](_0xf729('0x11'),_0x5e9b41,_0x2453b0);_0x534be7(_0x2453b0);});});}exports['ShowCmContact']=function(_0x408fb5){var _0x366f6f=this;return new Promise(function(_0x417e4a,_0x39714b){return db[_0xf729('0x1c')][_0xf729('0x1d')]({'raw':_0x408fb5[_0xf729('0x1e')]?_0x408fb5['options'][_0xf729('0x1f')]===undefined?!![]:![]:!![],'where':_0x408fb5[_0xf729('0x1e')]?_0x408fb5['options']['where']||null:null,'attributes':_0x408fb5[_0xf729('0x1e')]?_0x408fb5[_0xf729('0x1e')]['attributes']||null:null,'include':_0x408fb5['options']?_0x408fb5['options'][_0xf729('0x20')]?_[_0xf729('0x21')](_0x408fb5[_0xf729('0x1e')][_0xf729('0x20')],function(_0x3af4af){return{'model':db[_0x3af4af[_0xf729('0x22')]],'as':_0x3af4af['as'],'attributes':_0x3af4af[_0xf729('0x23')],'include':_0x3af4af[_0xf729('0x20')]?_[_0xf729('0x21')](_0x3af4af[_0xf729('0x20')],function(_0x3abb25){return{'model':db[_0x3abb25[_0xf729('0x22')]],'as':_0x3abb25['as'],'attributes':_0x3abb25[_0xf729('0x23')],'include':_0x3abb25[_0xf729('0x20')]?_['map'](_0x3abb25[_0xf729('0x20')],function(_0x52ceb9){return{'model':db[_0x52ceb9[_0xf729('0x22')]],'as':_0x52ceb9['as'],'attributes':_0x52ceb9['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0xc350c4){logger['info']('ShowCmContact',_0x408fb5);logger[_0xf729('0x13')](_0xf729('0x24'),_0x408fb5,JSON[_0xf729('0x15')](_0xc350c4));_0x417e4a(_0xc350c4);})[_0xf729('0x1b')](function(_0x4b0c44){logger['error']('ShowCmContact',_0x4b0c44['message'],_0x408fb5);_0x39714b(_0x366f6f['error'](0x1f4,_0x4b0c44[_0xf729('0x18')]));});});};exports[_0xf729('0x25')]=function(_0x4247ad){var _0x502dd0=this;return new Promise(function(_0x167dbe,_0x2867b6){return db[_0xf729('0x1c')][_0xf729('0x26')](_0x4247ad['body'],{'raw':_0x4247ad[_0xf729('0x1e')]?_0x4247ad['options'][_0xf729('0x1f')]===undefined?!![]:![]:!![]})['then'](function(_0x31443f){logger[_0xf729('0x19')](_0xf729('0x25'),_0x4247ad);logger['debug'](_0xf729('0x25'),_0x4247ad,JSON[_0xf729('0x15')](_0x31443f));_0x167dbe(_0x31443f);})[_0xf729('0x1b')](function(_0x548455){logger['error'](_0xf729('0x25'),_0x548455[_0xf729('0x18')],_0x4247ad);_0x2867b6(_0x502dd0[_0xf729('0x16')](0x1f4,_0x548455[_0xf729('0x18')]));});});};