Built motion from commit (unavailable).|2.4.4
[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 _0xb345=['raw','attributes','include','map','model','stringify','create','body','CreateCmContact','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','redis','localhost','socket.io-emitter','./cmContact.socket','register','then','CmContact,\x20%s,\x20%s','request\x20sent','debug','CmContact,\x20%s,\x20%s,\x20%s','error','code','message','info','result','catch','ShowCmContact','find','options'];(function(_0x27639f,_0x2377c3){var _0xc23e2c=function(_0x293de2){while(--_0x293de2){_0x27639f['push'](_0x27639f['shift']());}};_0xc23e2c(++_0x2377c3);}(_0xb345,0x1cc));var _0x5b34=function(_0x110c3d,_0x12ee06){_0x110c3d=_0x110c3d-0x0;var _0x226d67=_0xb345[_0x110c3d];return _0x226d67;};'use strict';var _=require(_0x5b34('0x0'));var util=require(_0x5b34('0x1'));var moment=require(_0x5b34('0x2'));var BPromise=require(_0x5b34('0x3'));var rs=require(_0x5b34('0x4'));var fs=require('fs');var Redis=require(_0x5b34('0x5'));var db=require(_0x5b34('0x6'))['db'];var utils=require(_0x5b34('0x7'));var logger=require(_0x5b34('0x8'))(_0x5b34('0x9'));var config=require('../../config/environment');var jayson=require(_0x5b34('0xa'));var client=jayson[_0x5b34('0xb')][_0x5b34('0xc')]({'port':0x232a});config[_0x5b34('0xd')]=_['defaults'](config['redis'],{'host':_0x5b34('0xe'),'port':0x18eb});var socket=require(_0x5b34('0xf'))(new Redis(config['redis']));require(_0x5b34('0x10'))[_0x5b34('0x11')](socket);function respondWithRpcPromise(_0x1538d1,_0x4a45c5,_0x3cb477){return new BPromise(function(_0x10e7f6,_0x253999){return client['request'](_0x1538d1,_0x3cb477)[_0x5b34('0x12')](function(_0x1d3f53){logger['info'](_0x5b34('0x13'),_0x4a45c5,_0x5b34('0x14'));logger[_0x5b34('0x15')](_0x5b34('0x16'),_0x4a45c5,_0x5b34('0x14'),JSON['stringify'](_0x1d3f53));if(_0x1d3f53[_0x5b34('0x17')]){if(_0x1d3f53[_0x5b34('0x17')][_0x5b34('0x18')]===0x1f4){logger[_0x5b34('0x17')](_0x5b34('0x13'),_0x4a45c5,_0x1d3f53[_0x5b34('0x17')][_0x5b34('0x19')]);return _0x253999(_0x1d3f53[_0x5b34('0x17')]['message']);}logger['error'](_0x5b34('0x13'),_0x4a45c5,_0x1d3f53[_0x5b34('0x17')][_0x5b34('0x19')]);return _0x10e7f6(_0x1d3f53[_0x5b34('0x17')][_0x5b34('0x19')]);}else{logger[_0x5b34('0x1a')](_0x5b34('0x13'),_0x4a45c5,'request\x20sent');_0x10e7f6(_0x1d3f53[_0x5b34('0x1b')][_0x5b34('0x19')]);}})[_0x5b34('0x1c')](function(_0x17b871){logger[_0x5b34('0x17')](_0x5b34('0x13'),_0x4a45c5,_0x17b871);_0x253999(_0x17b871);});});}exports[_0x5b34('0x1d')]=function(_0x8b761b){var _0x24b254=this;return new Promise(function(_0x898747,_0x1e4e73){return db['CmContact'][_0x5b34('0x1e')]({'raw':_0x8b761b[_0x5b34('0x1f')]?_0x8b761b[_0x5b34('0x1f')][_0x5b34('0x20')]===undefined?!![]:![]:!![],'where':_0x8b761b[_0x5b34('0x1f')]?_0x8b761b['options']['where']||null:null,'attributes':_0x8b761b['options']?_0x8b761b[_0x5b34('0x1f')][_0x5b34('0x21')]||null:null,'include':_0x8b761b[_0x5b34('0x1f')]?_0x8b761b['options'][_0x5b34('0x22')]?_[_0x5b34('0x23')](_0x8b761b['options'][_0x5b34('0x22')],function(_0x1d6ef2){return{'model':db[_0x1d6ef2[_0x5b34('0x24')]],'as':_0x1d6ef2['as'],'attributes':_0x1d6ef2['attributes'],'include':_0x1d6ef2[_0x5b34('0x22')]?_['map'](_0x1d6ef2[_0x5b34('0x22')],function(_0x4f9067){return{'model':db[_0x4f9067[_0x5b34('0x24')]],'as':_0x4f9067['as'],'attributes':_0x4f9067[_0x5b34('0x21')],'include':_0x4f9067[_0x5b34('0x22')]?_['map'](_0x4f9067[_0x5b34('0x22')],function(_0x59d9f1){return{'model':db[_0x59d9f1[_0x5b34('0x24')]],'as':_0x59d9f1['as'],'attributes':_0x59d9f1[_0x5b34('0x21')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x4b9fbe){logger[_0x5b34('0x1a')](_0x5b34('0x1d'),_0x8b761b);logger[_0x5b34('0x15')](_0x5b34('0x1d'),_0x8b761b,JSON[_0x5b34('0x25')](_0x4b9fbe));_0x898747(_0x4b9fbe);})[_0x5b34('0x1c')](function(_0x3573a8){logger[_0x5b34('0x17')]('ShowCmContact',_0x3573a8[_0x5b34('0x19')],_0x8b761b);_0x1e4e73(_0x24b254[_0x5b34('0x17')](0x1f4,_0x3573a8[_0x5b34('0x19')]));});});};exports['CreateCmContact']=function(_0x1fab4f){var _0x1bcaaa=this;return new Promise(function(_0x2de87e,_0x393e03){return db['CmContact'][_0x5b34('0x26')](_0x1fab4f[_0x5b34('0x27')],{'raw':_0x1fab4f['options']?_0x1fab4f[_0x5b34('0x1f')][_0x5b34('0x20')]===undefined?!![]:![]:!![]})[_0x5b34('0x12')](function(_0x146c95){logger[_0x5b34('0x1a')]('CreateCmContact',_0x1fab4f);logger[_0x5b34('0x15')]('CreateCmContact',_0x1fab4f,JSON[_0x5b34('0x25')](_0x146c95));_0x2de87e(_0x146c95);})[_0x5b34('0x1c')](function(_0x10abee){logger[_0x5b34('0x17')](_0x5b34('0x28'),_0x10abee[_0x5b34('0x19')],_0x1fab4f);_0x393e03(_0x1bcaaa[_0x5b34('0x17')](0x1f4,_0x10abee[_0x5b34('0x19')]));});});};