Built motion from commit (unavailable).|2.2.0
[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 _0x9794=['util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','redis','localhost','socket.io-emitter','./cmContact.socket','request','then','CmContact,\x20%s,\x20%s','CmContact,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','info','result','catch','ShowCmContact','options','raw','where','map','model','attributes','include','debug','create','body','CreateCmContact','lodash'];(function(_0x4fefc0,_0x3dfe44){var _0x14ffd0=function(_0x850e21){while(--_0x850e21){_0x4fefc0['push'](_0x4fefc0['shift']());}};_0x14ffd0(++_0x3dfe44);}(_0x9794,0x170));var _0x4979=function(_0x20b1a2,_0x5ba9fd){_0x20b1a2=_0x20b1a2-0x0;var _0x4ed38e=_0x9794[_0x20b1a2];return _0x4ed38e;};'use strict';var _=require(_0x4979('0x0'));var util=require(_0x4979('0x1'));var moment=require(_0x4979('0x2'));var BPromise=require(_0x4979('0x3'));var rs=require(_0x4979('0x4'));var fs=require('fs');var Redis=require(_0x4979('0x5'));var db=require(_0x4979('0x6'))['db'];var utils=require(_0x4979('0x7'));var logger=require(_0x4979('0x8'))(_0x4979('0x9'));var config=require(_0x4979('0xa'));var jayson=require(_0x4979('0xb'));var client=jayson[_0x4979('0xc')]['http']({'port':0x232a});config[_0x4979('0xd')]=_['defaults'](config[_0x4979('0xd')],{'host':_0x4979('0xe'),'port':0x18eb});var socket=require(_0x4979('0xf'))(new Redis(config[_0x4979('0xd')]));require(_0x4979('0x10'))['register'](socket);function respondWithRpcPromise(_0x14e7e6,_0x3518b5,_0x68c02a){return new BPromise(function(_0x217e49,_0x8d8289){return client[_0x4979('0x11')](_0x14e7e6,_0x68c02a)[_0x4979('0x12')](function(_0x3800df){logger['info'](_0x4979('0x13'),_0x3518b5,'request\x20sent');logger['debug'](_0x4979('0x14'),_0x3518b5,_0x4979('0x15'),JSON[_0x4979('0x16')](_0x3800df));if(_0x3800df['error']){if(_0x3800df[_0x4979('0x17')][_0x4979('0x18')]===0x1f4){logger['error'](_0x4979('0x13'),_0x3518b5,_0x3800df[_0x4979('0x17')][_0x4979('0x19')]);return _0x8d8289(_0x3800df['error'][_0x4979('0x19')]);}logger[_0x4979('0x17')]('CmContact,\x20%s,\x20%s',_0x3518b5,_0x3800df[_0x4979('0x17')]['message']);return _0x217e49(_0x3800df[_0x4979('0x17')][_0x4979('0x19')]);}else{logger[_0x4979('0x1a')](_0x4979('0x13'),_0x3518b5,_0x4979('0x15'));_0x217e49(_0x3800df[_0x4979('0x1b')][_0x4979('0x19')]);}})[_0x4979('0x1c')](function(_0x41d0f4){logger['error'](_0x4979('0x13'),_0x3518b5,_0x41d0f4);_0x8d8289(_0x41d0f4);});});}exports[_0x4979('0x1d')]=function(_0x21e365){var _0xb0695f=this;return new Promise(function(_0x43f9c0,_0x3bc4ca){return db['CmContact']['find']({'raw':_0x21e365[_0x4979('0x1e')]?_0x21e365[_0x4979('0x1e')][_0x4979('0x1f')]===undefined?!![]:![]:!![],'where':_0x21e365[_0x4979('0x1e')]?_0x21e365[_0x4979('0x1e')][_0x4979('0x20')]||null:null,'attributes':_0x21e365[_0x4979('0x1e')]?_0x21e365['options']['attributes']||null:null,'include':_0x21e365[_0x4979('0x1e')]?_0x21e365[_0x4979('0x1e')]['include']?_[_0x4979('0x21')](_0x21e365[_0x4979('0x1e')]['include'],function(_0x26e594){return{'model':db[_0x26e594[_0x4979('0x22')]],'as':_0x26e594['as'],'attributes':_0x26e594[_0x4979('0x23')],'include':_0x26e594[_0x4979('0x24')]?_[_0x4979('0x21')](_0x26e594['include'],function(_0xb5b104){return{'model':db[_0xb5b104['model']],'as':_0xb5b104['as'],'attributes':_0xb5b104[_0x4979('0x23')],'include':_0xb5b104[_0x4979('0x24')]?_['map'](_0xb5b104[_0x4979('0x24')],function(_0x9eda75){return{'model':db[_0x9eda75[_0x4979('0x22')]],'as':_0x9eda75['as'],'attributes':_0x9eda75['attributes']};}):[]};}):[]};}):[]:[]})[_0x4979('0x12')](function(_0x51ae5d){logger[_0x4979('0x1a')](_0x4979('0x1d'),_0x21e365);logger[_0x4979('0x25')](_0x4979('0x1d'),_0x21e365,JSON['stringify'](_0x51ae5d));_0x43f9c0(_0x51ae5d);})[_0x4979('0x1c')](function(_0x56224d){logger[_0x4979('0x17')](_0x4979('0x1d'),_0x56224d[_0x4979('0x19')],_0x21e365);_0x3bc4ca(_0xb0695f[_0x4979('0x17')](0x1f4,_0x56224d[_0x4979('0x19')]));});});};exports['CreateCmContact']=function(_0x526674){var _0x33c328=this;return new Promise(function(_0x287d59,_0x50a060){return db['CmContact'][_0x4979('0x26')](_0x526674[_0x4979('0x27')],{'raw':_0x526674[_0x4979('0x1e')]?_0x526674[_0x4979('0x1e')][_0x4979('0x1f')]===undefined?!![]:![]:!![]})['then'](function(_0x4f5982){logger[_0x4979('0x1a')](_0x4979('0x28'),_0x526674);logger[_0x4979('0x25')](_0x4979('0x28'),_0x526674,JSON[_0x4979('0x16')](_0x4f5982));_0x287d59(_0x4f5982);})[_0x4979('0x1c')](function(_0x469e9d){logger[_0x4979('0x17')]('CreateCmContact',_0x469e9d[_0x4979('0x19')],_0x526674);_0x50a060(_0x33c328['error'](0x1f4,_0x469e9d[_0x4979('0x19')]));});});};