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 _0x0850=['../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','redis','defaults','socket.io-emitter','./cmContact.socket','register','request','then','info','CmContact,\x20%s,\x20%s','request\x20sent','debug','CmContact,\x20%s,\x20%s,\x20%s','stringify','error','message','result','CmContact','find','options','raw','where','attributes','map','model','include','ShowCmContact','catch','CreateCmContact','lodash','util','moment','bluebird','ioredis','../../mysqldb'];(function(_0x3984a5,_0x14e8e0){var _0x1b80f8=function(_0x48e732){while(--_0x48e732){_0x3984a5['push'](_0x3984a5['shift']());}};_0x1b80f8(++_0x14e8e0);}(_0x0850,0x18a));var _0x0085=function(_0x3aa1f0,_0x3ee7c9){_0x3aa1f0=_0x3aa1f0-0x0;var _0x520581=_0x0850[_0x3aa1f0];return _0x520581;};'use strict';var _=require(_0x0085('0x0'));var util=require(_0x0085('0x1'));var moment=require(_0x0085('0x2'));var BPromise=require(_0x0085('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x0085('0x4'));var db=require(_0x0085('0x5'))['db'];var utils=require(_0x0085('0x6'));var logger=require(_0x0085('0x7'))(_0x0085('0x8'));var config=require(_0x0085('0x9'));var jayson=require(_0x0085('0xa'));var client=jayson['client'][_0x0085('0xb')]({'port':0x232a});config[_0x0085('0xc')]=_[_0x0085('0xd')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x0085('0xe'))(new Redis(config[_0x0085('0xc')]));require(_0x0085('0xf'))[_0x0085('0x10')](socket);function respondWithRpcPromise(_0x53cc67,_0x52d03d,_0x4f6f62){return new BPromise(function(_0x423f90,_0xd5c13a){return client[_0x0085('0x11')](_0x53cc67,_0x4f6f62)[_0x0085('0x12')](function(_0x4aaa9d){logger[_0x0085('0x13')](_0x0085('0x14'),_0x52d03d,_0x0085('0x15'));logger[_0x0085('0x16')](_0x0085('0x17'),_0x52d03d,'request\x20sent',JSON[_0x0085('0x18')](_0x4aaa9d));if(_0x4aaa9d[_0x0085('0x19')]){if(_0x4aaa9d[_0x0085('0x19')]['code']===0x1f4){logger[_0x0085('0x19')]('CmContact,\x20%s,\x20%s',_0x52d03d,_0x4aaa9d[_0x0085('0x19')][_0x0085('0x1a')]);return _0xd5c13a(_0x4aaa9d['error']['message']);}logger['error'](_0x0085('0x14'),_0x52d03d,_0x4aaa9d[_0x0085('0x19')][_0x0085('0x1a')]);return _0x423f90(_0x4aaa9d[_0x0085('0x19')]['message']);}else{logger[_0x0085('0x13')](_0x0085('0x14'),_0x52d03d,_0x0085('0x15'));_0x423f90(_0x4aaa9d[_0x0085('0x1b')][_0x0085('0x1a')]);}})['catch'](function(_0x11befc){logger[_0x0085('0x19')](_0x0085('0x14'),_0x52d03d,_0x11befc);_0xd5c13a(_0x11befc);});});}exports['ShowCmContact']=function(_0x304c9e){var _0x34151c=this;return new Promise(function(_0x2ca606,_0x2afb83){return db[_0x0085('0x1c')][_0x0085('0x1d')]({'raw':_0x304c9e[_0x0085('0x1e')]?_0x304c9e['options'][_0x0085('0x1f')]===undefined?!![]:![]:!![],'where':_0x304c9e['options']?_0x304c9e[_0x0085('0x1e')][_0x0085('0x20')]||null:null,'attributes':_0x304c9e[_0x0085('0x1e')]?_0x304c9e[_0x0085('0x1e')][_0x0085('0x21')]||null:null,'include':_0x304c9e[_0x0085('0x1e')]?_0x304c9e[_0x0085('0x1e')]['include']?_[_0x0085('0x22')](_0x304c9e[_0x0085('0x1e')]['include'],function(_0x566116){return{'model':db[_0x566116[_0x0085('0x23')]],'as':_0x566116['as'],'attributes':_0x566116['attributes'],'include':_0x566116['include']?_['map'](_0x566116[_0x0085('0x24')],function(_0x239461){return{'model':db[_0x239461[_0x0085('0x23')]],'as':_0x239461['as'],'attributes':_0x239461[_0x0085('0x21')],'include':_0x239461[_0x0085('0x24')]?_[_0x0085('0x22')](_0x239461[_0x0085('0x24')],function(_0x5657cf){return{'model':db[_0x5657cf[_0x0085('0x23')]],'as':_0x5657cf['as'],'attributes':_0x5657cf[_0x0085('0x21')]};}):[]};}):[]};}):[]:[]})[_0x0085('0x12')](function(_0x5c60e8){logger[_0x0085('0x13')](_0x0085('0x25'),_0x304c9e);logger[_0x0085('0x16')](_0x0085('0x25'),_0x304c9e,JSON[_0x0085('0x18')](_0x5c60e8));_0x2ca606(_0x5c60e8);})[_0x0085('0x26')](function(_0x3e7696){logger[_0x0085('0x19')](_0x0085('0x25'),_0x3e7696[_0x0085('0x1a')],_0x304c9e);_0x2afb83(_0x34151c[_0x0085('0x19')](0x1f4,_0x3e7696[_0x0085('0x1a')]));});});};exports[_0x0085('0x27')]=function(_0x58ed95){var _0x53a1b3=this;return new Promise(function(_0x3f9fe9,_0x1d297d){return db[_0x0085('0x1c')]['create'](_0x58ed95['body'],{'raw':_0x58ed95[_0x0085('0x1e')]?_0x58ed95['options'][_0x0085('0x1f')]===undefined?!![]:![]:!![]})[_0x0085('0x12')](function(_0x5e75bb){logger[_0x0085('0x13')](_0x0085('0x27'),_0x58ed95);logger[_0x0085('0x16')]('CreateCmContact',_0x58ed95,JSON[_0x0085('0x18')](_0x5e75bb));_0x3f9fe9(_0x5e75bb);})['catch'](function(_0x3df024){logger[_0x0085('0x19')](_0x0085('0x27'),_0x3df024[_0x0085('0x1a')],_0x58ed95);_0x1d297d(_0x53a1b3[_0x0085('0x19')](0x1f4,_0x3df024[_0x0085('0x1a')]));});});};