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 _0x99b9=['../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','./cmContact.socket','request','then','info','CmContact,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','ShowCmContact','find','options','where','attributes','include','map','model','debug','CreateCmContact','CmContact','body','raw','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils'];(function(_0x51fe5f,_0x1d8632){var _0x4abce9=function(_0x34afb7){while(--_0x34afb7){_0x51fe5f['push'](_0x51fe5f['shift']());}};_0x4abce9(++_0x1d8632);}(_0x99b9,0x141));var _0x999b=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x99b9[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0x999b('0x0'));var util=require('util');var moment=require(_0x999b('0x1'));var BPromise=require(_0x999b('0x2'));var rs=require(_0x999b('0x3'));var fs=require('fs');var Redis=require(_0x999b('0x4'));var db=require(_0x999b('0x5'))['db'];var utils=require(_0x999b('0x6'));var logger=require(_0x999b('0x7'))(_0x999b('0x8'));var config=require(_0x999b('0x9'));var jayson=require(_0x999b('0xa'));var client=jayson[_0x999b('0xb')][_0x999b('0xc')]({'port':0x232a});config[_0x999b('0xd')]=_[_0x999b('0xe')](config[_0x999b('0xd')],{'host':_0x999b('0xf'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x999b('0xd')]));require(_0x999b('0x10'))['register'](socket);function respondWithRpcPromise(_0x1d7ec1,_0x34ff04,_0x13023b){return new BPromise(function(_0x3333e0,_0x223b6a){return client[_0x999b('0x11')](_0x1d7ec1,_0x13023b)[_0x999b('0x12')](function(_0x5bae09){logger[_0x999b('0x13')](_0x999b('0x14'),_0x34ff04,_0x999b('0x15'));logger['debug']('CmContact,\x20%s,\x20%s,\x20%s',_0x34ff04,_0x999b('0x15'),JSON[_0x999b('0x16')](_0x5bae09));if(_0x5bae09[_0x999b('0x17')]){if(_0x5bae09['error'][_0x999b('0x18')]===0x1f4){logger['error'](_0x999b('0x14'),_0x34ff04,_0x5bae09['error'][_0x999b('0x19')]);return _0x223b6a(_0x5bae09[_0x999b('0x17')][_0x999b('0x19')]);}logger[_0x999b('0x17')](_0x999b('0x14'),_0x34ff04,_0x5bae09[_0x999b('0x17')][_0x999b('0x19')]);return _0x3333e0(_0x5bae09[_0x999b('0x17')][_0x999b('0x19')]);}else{logger[_0x999b('0x13')](_0x999b('0x14'),_0x34ff04,_0x999b('0x15'));_0x3333e0(_0x5bae09[_0x999b('0x1a')][_0x999b('0x19')]);}})[_0x999b('0x1b')](function(_0x2d94b5){logger[_0x999b('0x17')](_0x999b('0x14'),_0x34ff04,_0x2d94b5);_0x223b6a(_0x2d94b5);});});}exports[_0x999b('0x1c')]=function(_0x16abce){var _0x3f28c2=this;return new Promise(function(_0x5e2262,_0x319a6a){return db['CmContact'][_0x999b('0x1d')]({'raw':_0x16abce['options']?_0x16abce[_0x999b('0x1e')]['raw']===undefined?!![]:![]:!![],'where':_0x16abce[_0x999b('0x1e')]?_0x16abce[_0x999b('0x1e')][_0x999b('0x1f')]||null:null,'attributes':_0x16abce['options']?_0x16abce['options'][_0x999b('0x20')]||null:null,'include':_0x16abce[_0x999b('0x1e')]?_0x16abce[_0x999b('0x1e')][_0x999b('0x21')]?_[_0x999b('0x22')](_0x16abce[_0x999b('0x1e')][_0x999b('0x21')],function(_0x44dbf3){return{'model':db[_0x44dbf3[_0x999b('0x23')]],'as':_0x44dbf3['as'],'attributes':_0x44dbf3[_0x999b('0x20')],'include':_0x44dbf3['include']?_[_0x999b('0x22')](_0x44dbf3[_0x999b('0x21')],function(_0x24813e){return{'model':db[_0x24813e[_0x999b('0x23')]],'as':_0x24813e['as'],'attributes':_0x24813e['attributes'],'include':_0x24813e[_0x999b('0x21')]?_[_0x999b('0x22')](_0x24813e[_0x999b('0x21')],function(_0x413033){return{'model':db[_0x413033[_0x999b('0x23')]],'as':_0x413033['as'],'attributes':_0x413033[_0x999b('0x20')]};}):[]};}):[]};}):[]:[]})[_0x999b('0x12')](function(_0x4531eb){logger[_0x999b('0x13')](_0x999b('0x1c'),_0x16abce);logger[_0x999b('0x24')](_0x999b('0x1c'),_0x16abce,JSON[_0x999b('0x16')](_0x4531eb));_0x5e2262(_0x4531eb);})[_0x999b('0x1b')](function(_0x22b20d){logger['error'](_0x999b('0x1c'),_0x22b20d[_0x999b('0x19')],_0x16abce);_0x319a6a(_0x3f28c2[_0x999b('0x17')](0x1f4,_0x22b20d['message']));});});};exports[_0x999b('0x25')]=function(_0x2e548d){var _0x4082d6=this;return new Promise(function(_0x838e2e,_0x39c991){return db[_0x999b('0x26')]['create'](_0x2e548d[_0x999b('0x27')],{'raw':_0x2e548d[_0x999b('0x1e')]?_0x2e548d[_0x999b('0x1e')][_0x999b('0x28')]===undefined?!![]:![]:!![]})[_0x999b('0x12')](function(_0x43fe8c){logger['info'](_0x999b('0x25'),_0x2e548d);logger[_0x999b('0x24')]('CreateCmContact',_0x2e548d,JSON['stringify'](_0x43fe8c));_0x838e2e(_0x43fe8c);})['catch'](function(_0x48768a){logger['error'](_0x999b('0x25'),_0x48768a[_0x999b('0x19')],_0x2e548d);_0x39c991(_0x4082d6[_0x999b('0x17')](0x1f4,_0x48768a[_0x999b('0x19')]));});});};