Built motion from commit (unavailable).|2.4.18
[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 _0xe442=['./cmContact.socket','request','then','CmContact,\x20%s,\x20%s','debug','CmContact,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','info','result','catch','ShowCmContact','CmContact','options','where','attributes','include','map','model','CreateCmContact','create','body','raw','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','http','redis','localhost'];(function(_0x460b32,_0x29c4ea){var _0x3ae731=function(_0x591b36){while(--_0x591b36){_0x460b32['push'](_0x460b32['shift']());}};_0x3ae731(++_0x29c4ea);}(_0xe442,0xb6));var _0x2e44=function(_0x1deb03,_0xd05ad8){_0x1deb03=_0x1deb03-0x0;var _0x189fe7=_0xe442[_0x1deb03];return _0x189fe7;};'use strict';var _=require(_0x2e44('0x0'));var util=require(_0x2e44('0x1'));var moment=require(_0x2e44('0x2'));var BPromise=require(_0x2e44('0x3'));var rs=require(_0x2e44('0x4'));var fs=require('fs');var Redis=require(_0x2e44('0x5'));var db=require(_0x2e44('0x6'))['db'];var utils=require(_0x2e44('0x7'));var logger=require(_0x2e44('0x8'))('rpc');var config=require(_0x2e44('0x9'));var jayson=require('jayson/promise');var client=jayson['client'][_0x2e44('0xa')]({'port':0x232a});config[_0x2e44('0xb')]=_['defaults'](config[_0x2e44('0xb')],{'host':_0x2e44('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x2e44('0xb')]));require(_0x2e44('0xd'))['register'](socket);function respondWithRpcPromise(_0xbab606,_0x2d5cca,_0x5ae881){return new BPromise(function(_0x5db5c1,_0x97f15){return client[_0x2e44('0xe')](_0xbab606,_0x5ae881)[_0x2e44('0xf')](function(_0x1e9653){logger['info'](_0x2e44('0x10'),_0x2d5cca,'request\x20sent');logger[_0x2e44('0x11')](_0x2e44('0x12'),_0x2d5cca,_0x2e44('0x13'),JSON[_0x2e44('0x14')](_0x1e9653));if(_0x1e9653[_0x2e44('0x15')]){if(_0x1e9653['error'][_0x2e44('0x16')]===0x1f4){logger[_0x2e44('0x15')]('CmContact,\x20%s,\x20%s',_0x2d5cca,_0x1e9653[_0x2e44('0x15')]['message']);return _0x97f15(_0x1e9653[_0x2e44('0x15')][_0x2e44('0x17')]);}logger['error'](_0x2e44('0x10'),_0x2d5cca,_0x1e9653[_0x2e44('0x15')][_0x2e44('0x17')]);return _0x5db5c1(_0x1e9653[_0x2e44('0x15')][_0x2e44('0x17')]);}else{logger[_0x2e44('0x18')]('CmContact,\x20%s,\x20%s',_0x2d5cca,'request\x20sent');_0x5db5c1(_0x1e9653[_0x2e44('0x19')][_0x2e44('0x17')]);}})[_0x2e44('0x1a')](function(_0x525db9){logger[_0x2e44('0x15')]('CmContact,\x20%s,\x20%s',_0x2d5cca,_0x525db9);_0x97f15(_0x525db9);});});}exports[_0x2e44('0x1b')]=function(_0x6a604e){var _0x3e845a=this;return new Promise(function(_0x38ff87,_0x1e084d){return db[_0x2e44('0x1c')]['find']({'raw':_0x6a604e[_0x2e44('0x1d')]?_0x6a604e['options']['raw']===undefined?!![]:![]:!![],'where':_0x6a604e['options']?_0x6a604e[_0x2e44('0x1d')][_0x2e44('0x1e')]||null:null,'attributes':_0x6a604e[_0x2e44('0x1d')]?_0x6a604e[_0x2e44('0x1d')][_0x2e44('0x1f')]||null:null,'include':_0x6a604e['options']?_0x6a604e[_0x2e44('0x1d')][_0x2e44('0x20')]?_[_0x2e44('0x21')](_0x6a604e[_0x2e44('0x1d')][_0x2e44('0x20')],function(_0x3ed956){return{'model':db[_0x3ed956[_0x2e44('0x22')]],'as':_0x3ed956['as'],'attributes':_0x3ed956[_0x2e44('0x1f')],'include':_0x3ed956[_0x2e44('0x20')]?_[_0x2e44('0x21')](_0x3ed956[_0x2e44('0x20')],function(_0x29ac33){return{'model':db[_0x29ac33[_0x2e44('0x22')]],'as':_0x29ac33['as'],'attributes':_0x29ac33['attributes'],'include':_0x29ac33['include']?_[_0x2e44('0x21')](_0x29ac33[_0x2e44('0x20')],function(_0x4581a2){return{'model':db[_0x4581a2[_0x2e44('0x22')]],'as':_0x4581a2['as'],'attributes':_0x4581a2[_0x2e44('0x1f')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x4b805b){logger[_0x2e44('0x18')]('ShowCmContact',_0x6a604e);logger[_0x2e44('0x11')](_0x2e44('0x1b'),_0x6a604e,JSON[_0x2e44('0x14')](_0x4b805b));_0x38ff87(_0x4b805b);})[_0x2e44('0x1a')](function(_0x227563){logger[_0x2e44('0x15')](_0x2e44('0x1b'),_0x227563['message'],_0x6a604e);_0x1e084d(_0x3e845a[_0x2e44('0x15')](0x1f4,_0x227563[_0x2e44('0x17')]));});});};exports[_0x2e44('0x23')]=function(_0x5a0a26){var _0x34945d=this;return new Promise(function(_0x3d8efa,_0x438b60){return db[_0x2e44('0x1c')][_0x2e44('0x24')](_0x5a0a26[_0x2e44('0x25')],{'raw':_0x5a0a26[_0x2e44('0x1d')]?_0x5a0a26[_0x2e44('0x1d')][_0x2e44('0x26')]===undefined?!![]:![]:!![]})[_0x2e44('0xf')](function(_0x2dbae5){logger[_0x2e44('0x18')](_0x2e44('0x23'),_0x5a0a26);logger[_0x2e44('0x11')](_0x2e44('0x23'),_0x5a0a26,JSON[_0x2e44('0x14')](_0x2dbae5));_0x3d8efa(_0x2dbae5);})[_0x2e44('0x1a')](function(_0x2a3d68){logger['error']('CreateCmContact',_0x2a3d68[_0x2e44('0x17')],_0x5a0a26);_0x438b60(_0x34945d[_0x2e44('0x15')](0x1f4,_0x2a3d68[_0x2e44('0x17')]));});});};