Built motion from commit ab870f9e.|2.5.44
[motion2.git] / server / api / openchannelAccount / openchannelAccount.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 _0xcf66=['debug','OpenchannelAccount,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','message','OpenchannelAccount,\x20%s,\x20%s','info','catch','lodash','util','moment','randomstring','ioredis','../../config/logger','rpc','jayson/promise','client','http','defaults','redis','localhost','socket.io-emitter','./openchannelAccount.socket','request','then'];(function(_0x56c25a,_0x15157d){var _0x4f1914=function(_0x597c5c){while(--_0x597c5c){_0x56c25a['push'](_0x56c25a['shift']());}};_0x4f1914(++_0x15157d);}(_0xcf66,0x71));var _0x6cf6=function(_0x54615d,_0x484a97){_0x54615d=_0x54615d-0x0;var _0x2afd34=_0xcf66[_0x54615d];return _0x2afd34;};'use strict';var _=require(_0x6cf6('0x0'));var util=require(_0x6cf6('0x1'));var moment=require(_0x6cf6('0x2'));var BPromise=require('bluebird');var rs=require(_0x6cf6('0x3'));var fs=require('fs');var Redis=require(_0x6cf6('0x4'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x6cf6('0x5'))(_0x6cf6('0x6'));var config=require('../../config/environment');var jayson=require(_0x6cf6('0x7'));var client=jayson[_0x6cf6('0x8')][_0x6cf6('0x9')]({'port':0x232a});config['redis']=_[_0x6cf6('0xa')](config[_0x6cf6('0xb')],{'host':_0x6cf6('0xc'),'port':0x18eb});var socket=require(_0x6cf6('0xd'))(new Redis(config[_0x6cf6('0xb')]));require(_0x6cf6('0xe'))['register'](socket);function respondWithRpcPromise(_0x58378c,_0x5b7f4e,_0x8e90e){return new BPromise(function(_0x504c98,_0x1fdf80){return client[_0x6cf6('0xf')](_0x58378c,_0x8e90e)[_0x6cf6('0x10')](function(_0x3f7fc1){logger['info']('OpenchannelAccount,\x20%s,\x20%s',_0x5b7f4e,'request\x20sent');logger[_0x6cf6('0x11')](_0x6cf6('0x12'),_0x5b7f4e,_0x6cf6('0x13'),JSON[_0x6cf6('0x14')](_0x3f7fc1));if(_0x3f7fc1[_0x6cf6('0x15')]){if(_0x3f7fc1[_0x6cf6('0x15')]['code']===0x1f4){logger[_0x6cf6('0x15')]('OpenchannelAccount,\x20%s,\x20%s',_0x5b7f4e,_0x3f7fc1[_0x6cf6('0x15')][_0x6cf6('0x16')]);return _0x1fdf80(_0x3f7fc1['error'][_0x6cf6('0x16')]);}logger[_0x6cf6('0x15')](_0x6cf6('0x17'),_0x5b7f4e,_0x3f7fc1[_0x6cf6('0x15')][_0x6cf6('0x16')]);return _0x504c98(_0x3f7fc1[_0x6cf6('0x15')][_0x6cf6('0x16')]);}else{logger[_0x6cf6('0x18')](_0x6cf6('0x17'),_0x5b7f4e,_0x6cf6('0x13'));_0x504c98(_0x3f7fc1['result'][_0x6cf6('0x16')]);}})[_0x6cf6('0x19')](function(_0x22ab0){logger['error'](_0x6cf6('0x17'),_0x5b7f4e,_0x22ab0);_0x1fdf80(_0x22ab0);});});}