Built motion from commit (unavailable).|2.5.2
[motion2.git] / server / api / openchannelMessage / openchannelMessage.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 _0xd916=['error','code','message','CreateOpenchannelMessage','OpenchannelMessage','create','body','options','raw','catch','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/environment','jayson/promise','http','redis','defaults','localhost','socket.io-emitter','request','then','info','OpenchannelMessage,\x20%s,\x20%s','request\x20sent','debug','OpenchannelMessage,\x20%s,\x20%s,\x20%s','stringify'];(function(_0x1f52ea,_0x1dd436){var _0x2d4b16=function(_0x3cee20){while(--_0x3cee20){_0x1f52ea['push'](_0x1f52ea['shift']());}};_0x2d4b16(++_0x1dd436);}(_0xd916,0x18a));var _0x6d91=function(_0x42cfc3,_0x581094){_0x42cfc3=_0x42cfc3-0x0;var _0x506c47=_0xd916[_0x42cfc3];return _0x506c47;};'use strict';var _=require(_0x6d91('0x0'));var util=require(_0x6d91('0x1'));var moment=require(_0x6d91('0x2'));var BPromise=require(_0x6d91('0x3'));var rs=require(_0x6d91('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x6d91('0x5'))['db'];var utils=require(_0x6d91('0x6'));var logger=require('../../config/logger')('rpc');var config=require(_0x6d91('0x7'));var jayson=require(_0x6d91('0x8'));var client=jayson['client'][_0x6d91('0x9')]({'port':0x232a});config[_0x6d91('0xa')]=_[_0x6d91('0xb')](config[_0x6d91('0xa')],{'host':_0x6d91('0xc'),'port':0x18eb});var socket=require(_0x6d91('0xd'))(new Redis(config[_0x6d91('0xa')]));require('./openchannelMessage.socket')['register'](socket);function respondWithRpcPromise(_0x598756,_0x5ae90d,_0xab3051){return new BPromise(function(_0xae0aa1,_0x2e2cdd){return client[_0x6d91('0xe')](_0x598756,_0xab3051)[_0x6d91('0xf')](function(_0x540ddd){logger[_0x6d91('0x10')](_0x6d91('0x11'),_0x5ae90d,_0x6d91('0x12'));logger[_0x6d91('0x13')](_0x6d91('0x14'),_0x5ae90d,_0x6d91('0x12'),JSON[_0x6d91('0x15')](_0x540ddd));if(_0x540ddd[_0x6d91('0x16')]){if(_0x540ddd[_0x6d91('0x16')][_0x6d91('0x17')]===0x1f4){logger[_0x6d91('0x16')](_0x6d91('0x11'),_0x5ae90d,_0x540ddd[_0x6d91('0x16')][_0x6d91('0x18')]);return _0x2e2cdd(_0x540ddd[_0x6d91('0x16')]['message']);}logger[_0x6d91('0x16')](_0x6d91('0x11'),_0x5ae90d,_0x540ddd[_0x6d91('0x16')][_0x6d91('0x18')]);return _0xae0aa1(_0x540ddd[_0x6d91('0x16')][_0x6d91('0x18')]);}else{logger['info'](_0x6d91('0x11'),_0x5ae90d,'request\x20sent');_0xae0aa1(_0x540ddd['result'][_0x6d91('0x18')]);}})['catch'](function(_0xa8cc9){logger['error']('OpenchannelMessage,\x20%s,\x20%s',_0x5ae90d,_0xa8cc9);_0x2e2cdd(_0xa8cc9);});});}exports[_0x6d91('0x19')]=function(_0x2a0ce7){var _0xa7d6e=this;return new Promise(function(_0x4b5980,_0x36f8fd){return db[_0x6d91('0x1a')][_0x6d91('0x1b')](_0x2a0ce7[_0x6d91('0x1c')],{'raw':_0x2a0ce7[_0x6d91('0x1d')]?_0x2a0ce7[_0x6d91('0x1d')][_0x6d91('0x1e')]===undefined?!![]:![]:!![]})[_0x6d91('0xf')](function(_0x468142){logger[_0x6d91('0x10')](_0x6d91('0x19'),_0x2a0ce7);logger[_0x6d91('0x13')]('CreateOpenchannelMessage',_0x2a0ce7,JSON[_0x6d91('0x15')](_0x468142));_0x4b5980(_0x468142);})[_0x6d91('0x1f')](function(_0x34ed05){logger['error'](_0x6d91('0x19'),_0x34ed05[_0x6d91('0x18')],_0x2a0ce7);_0x36f8fd(_0xa7d6e['error'](0x1f4,_0x34ed05[_0x6d91('0x18')]));});});};