Built motion from commit (unavailable).|2.3.4
[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 _0x1f0a=['../../config/utils','../../config/logger','rpc','jayson/promise','client','defaults','redis','localhost','socket.io-emitter','register','request','info','OpenchannelMessage,\x20%s,\x20%s','request\x20sent','debug','OpenchannelMessage,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','CreateOpenchannelMessage','create','body','options','then','util','moment','bluebird','randomstring','ioredis'];(function(_0x39b38f,_0x15633f){var _0x358b99=function(_0x4b91eb){while(--_0x4b91eb){_0x39b38f['push'](_0x39b38f['shift']());}};_0x358b99(++_0x15633f);}(_0x1f0a,0x1cc));var _0xa1f0=function(_0x855b1c,_0x131bc8){_0x855b1c=_0x855b1c-0x0;var _0x5b4c9e=_0x1f0a[_0x855b1c];return _0x5b4c9e;};'use strict';var _=require('lodash');var util=require(_0xa1f0('0x0'));var moment=require(_0xa1f0('0x1'));var BPromise=require(_0xa1f0('0x2'));var rs=require(_0xa1f0('0x3'));var fs=require('fs');var Redis=require(_0xa1f0('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xa1f0('0x5'));var logger=require(_0xa1f0('0x6'))(_0xa1f0('0x7'));var config=require('../../config/environment');var jayson=require(_0xa1f0('0x8'));var client=jayson[_0xa1f0('0x9')]['http']({'port':0x232a});config['redis']=_[_0xa1f0('0xa')](config[_0xa1f0('0xb')],{'host':_0xa1f0('0xc'),'port':0x18eb});var socket=require(_0xa1f0('0xd'))(new Redis(config[_0xa1f0('0xb')]));require('./openchannelMessage.socket')[_0xa1f0('0xe')](socket);function respondWithRpcPromise(_0x1e5cc3,_0x3457ae,_0x38e001){return new BPromise(function(_0x55b2d0,_0x4d3500){return client[_0xa1f0('0xf')](_0x1e5cc3,_0x38e001)['then'](function(_0x349e58){logger[_0xa1f0('0x10')](_0xa1f0('0x11'),_0x3457ae,_0xa1f0('0x12'));logger[_0xa1f0('0x13')](_0xa1f0('0x14'),_0x3457ae,_0xa1f0('0x12'),JSON[_0xa1f0('0x15')](_0x349e58));if(_0x349e58[_0xa1f0('0x16')]){if(_0x349e58[_0xa1f0('0x16')]['code']===0x1f4){logger[_0xa1f0('0x16')](_0xa1f0('0x11'),_0x3457ae,_0x349e58['error'][_0xa1f0('0x17')]);return _0x4d3500(_0x349e58['error'][_0xa1f0('0x17')]);}logger['error'](_0xa1f0('0x11'),_0x3457ae,_0x349e58['error']['message']);return _0x55b2d0(_0x349e58[_0xa1f0('0x16')]['message']);}else{logger[_0xa1f0('0x10')]('OpenchannelMessage,\x20%s,\x20%s',_0x3457ae,'request\x20sent');_0x55b2d0(_0x349e58[_0xa1f0('0x18')][_0xa1f0('0x17')]);}})[_0xa1f0('0x19')](function(_0x17bc8b){logger['error'](_0xa1f0('0x11'),_0x3457ae,_0x17bc8b);_0x4d3500(_0x17bc8b);});});}exports[_0xa1f0('0x1a')]=function(_0x52d6ee){var _0x379cce=this;return new Promise(function(_0x9601a0,_0x3c868f){return db['OpenchannelMessage'][_0xa1f0('0x1b')](_0x52d6ee[_0xa1f0('0x1c')],{'raw':_0x52d6ee[_0xa1f0('0x1d')]?_0x52d6ee[_0xa1f0('0x1d')]['raw']===undefined?!![]:![]:!![]})[_0xa1f0('0x1e')](function(_0x3c6604){logger[_0xa1f0('0x10')](_0xa1f0('0x1a'),_0x52d6ee);logger[_0xa1f0('0x13')]('CreateOpenchannelMessage',_0x52d6ee,JSON[_0xa1f0('0x15')](_0x3c6604));_0x9601a0(_0x3c6604);})[_0xa1f0('0x19')](function(_0x125e5c){logger['error'](_0xa1f0('0x1a'),_0x125e5c[_0xa1f0('0x17')],_0x52d6ee);_0x3c868f(_0x379cce[_0xa1f0('0x16')](0x1f4,_0x125e5c[_0xa1f0('0x17')]));});});};