Built motion from commit (unavailable).|2.0.75
[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 _0x9513=['randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','socket.io-emitter','localhost','./cmContact.socket','request','info','CmContact,\x20%s,\x20%s','request\x20sent','debug','CmContact,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','ShowCmContact','CmContact','options','raw','attributes','include','map','model','then','CreateCmContact','body','lodash','moment','bluebird'];(function(_0x31ed0f,_0x4e649d){var _0x44dab5=function(_0x16283d){while(--_0x16283d){_0x31ed0f['push'](_0x31ed0f['shift']());}};_0x44dab5(++_0x4e649d);}(_0x9513,0x12d));var _0x3951=function(_0x2f1064,_0x26236b){_0x2f1064=_0x2f1064-0x0;var _0xadb96d=_0x9513[_0x2f1064];return _0xadb96d;};'use strict';var _=require(_0x3951('0x0'));var util=require('util');var moment=require(_0x3951('0x1'));var BPromise=require(_0x3951('0x2'));var rs=require(_0x3951('0x3'));var fs=require('fs');var db=require(_0x3951('0x4'))['db'];var utils=require(_0x3951('0x5'));var logger=require(_0x3951('0x6'))(_0x3951('0x7'));var config=require(_0x3951('0x8'));var jayson=require(_0x3951('0x9'));var client=jayson[_0x3951('0xa')][_0x3951('0xb')]({'port':0x232a});var socket=require(_0x3951('0xc'))({'host':_0x3951('0xd'),'port':0x18eb});require(_0x3951('0xe'))['register'](socket);function respondWithRpcPromise(_0x29f502,_0x51c7ae,_0x13b161){return new BPromise(function(_0x27f5b5,_0x3be539){return client[_0x3951('0xf')](_0x29f502,_0x13b161)['then'](function(_0x3d4b85){logger[_0x3951('0x10')](_0x3951('0x11'),_0x51c7ae,_0x3951('0x12'));logger[_0x3951('0x13')](_0x3951('0x14'),_0x51c7ae,_0x3951('0x12'),JSON[_0x3951('0x15')](_0x3d4b85));if(_0x3d4b85[_0x3951('0x16')]){if(_0x3d4b85[_0x3951('0x16')][_0x3951('0x17')]===0x1f4){logger['error']('CmContact,\x20%s,\x20%s',_0x51c7ae,_0x3d4b85[_0x3951('0x16')][_0x3951('0x18')]);return _0x3be539(_0x3d4b85['error'][_0x3951('0x18')]);}logger[_0x3951('0x16')](_0x3951('0x11'),_0x51c7ae,_0x3d4b85[_0x3951('0x16')][_0x3951('0x18')]);return _0x27f5b5(_0x3d4b85[_0x3951('0x16')][_0x3951('0x18')]);}else{logger[_0x3951('0x10')](_0x3951('0x11'),_0x51c7ae,_0x3951('0x12'));_0x27f5b5(_0x3d4b85[_0x3951('0x19')][_0x3951('0x18')]);}})[_0x3951('0x1a')](function(_0xfd46ad){logger['error'](_0x3951('0x11'),_0x51c7ae,_0xfd46ad);_0x3be539(_0xfd46ad);});});}exports[_0x3951('0x1b')]=function(_0x924b3f){var _0x1fca2c=this;return new Promise(function(_0x497f2d,_0x2268a8){return db[_0x3951('0x1c')]['find']({'raw':_0x924b3f[_0x3951('0x1d')]?_0x924b3f[_0x3951('0x1d')][_0x3951('0x1e')]===undefined?!![]:![]:!![],'where':_0x924b3f[_0x3951('0x1d')]?_0x924b3f[_0x3951('0x1d')]['where']||null:null,'attributes':_0x924b3f['options']?_0x924b3f[_0x3951('0x1d')][_0x3951('0x1f')]||null:null,'include':_0x924b3f[_0x3951('0x1d')]?_0x924b3f[_0x3951('0x1d')][_0x3951('0x20')]?_[_0x3951('0x21')](_0x924b3f['options'][_0x3951('0x20')],function(_0x33aaf1){return{'model':db[_0x33aaf1[_0x3951('0x22')]],'as':_0x33aaf1['as'],'attributes':_0x33aaf1[_0x3951('0x1f')],'include':_0x33aaf1['include']?_['map'](_0x33aaf1[_0x3951('0x20')],function(_0xede5dd){return{'model':db[_0xede5dd['model']],'as':_0xede5dd['as'],'attributes':_0xede5dd[_0x3951('0x1f')],'include':_0xede5dd[_0x3951('0x20')]?_['map'](_0xede5dd['include'],function(_0xe94b6c){return{'model':db[_0xe94b6c[_0x3951('0x22')]],'as':_0xe94b6c['as'],'attributes':_0xe94b6c[_0x3951('0x1f')]};}):[]};}):[]};}):[]:[]})[_0x3951('0x23')](function(_0x82a2cc){logger['info'](_0x3951('0x1b'),_0x924b3f);logger['debug'](_0x3951('0x1b'),_0x924b3f,JSON[_0x3951('0x15')](_0x82a2cc));_0x497f2d(_0x82a2cc);})['catch'](function(_0x281140){logger[_0x3951('0x16')]('ShowCmContact',_0x281140[_0x3951('0x18')],_0x924b3f);_0x2268a8(_0x1fca2c[_0x3951('0x16')](0x1f4,_0x281140[_0x3951('0x18')]));});});};exports[_0x3951('0x24')]=function(_0x26d96f){var _0x557cf0=this;return new Promise(function(_0xc93191,_0x2760aa){return db[_0x3951('0x1c')]['create'](_0x26d96f[_0x3951('0x25')],{'raw':_0x26d96f[_0x3951('0x1d')]?_0x26d96f['options'][_0x3951('0x1e')]===undefined?!![]:![]:!![]})[_0x3951('0x23')](function(_0x1bbd83){logger[_0x3951('0x10')](_0x3951('0x24'),_0x26d96f);logger[_0x3951('0x13')](_0x3951('0x24'),_0x26d96f,JSON[_0x3951('0x15')](_0x1bbd83));_0xc93191(_0x1bbd83);})['catch'](function(_0x5c5e9a){logger['error']('CreateCmContact',_0x5c5e9a[_0x3951('0x18')],_0x26d96f);_0x2760aa(_0x557cf0[_0x3951('0x16')](0x1f4,_0x5c5e9a[_0x3951('0x18')]));});});};