Built motion from commit (unavailable).|2.2.0
[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 _0xe1e7=['info','request\x20sent','OpenchannelMessage,\x20%s,\x20%s,\x20%s','error','code','OpenchannelMessage,\x20%s,\x20%s','message','result','catch','options','debug','CreateOpenchannelMessage','lodash','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','./openchannelMessage.socket','register','request','then'];(function(_0x4307a5,_0x148615){var _0x6c146e=function(_0x493c31){while(--_0x493c31){_0x4307a5['push'](_0x4307a5['shift']());}};_0x6c146e(++_0x148615);}(_0xe1e7,0xe5));var _0x7e1e=function(_0x36740a,_0x26db45){_0x36740a=_0x36740a-0x0;var _0x2c04bb=_0xe1e7[_0x36740a];return _0x2c04bb;};'use strict';var _=require(_0x7e1e('0x0'));var util=require('util');var moment=require(_0x7e1e('0x1'));var BPromise=require('bluebird');var rs=require(_0x7e1e('0x2'));var fs=require('fs');var Redis=require(_0x7e1e('0x3'));var db=require(_0x7e1e('0x4'))['db'];var utils=require(_0x7e1e('0x5'));var logger=require(_0x7e1e('0x6'))(_0x7e1e('0x7'));var config=require(_0x7e1e('0x8'));var jayson=require(_0x7e1e('0x9'));var client=jayson[_0x7e1e('0xa')][_0x7e1e('0xb')]({'port':0x232a});config[_0x7e1e('0xc')]=_[_0x7e1e('0xd')](config[_0x7e1e('0xc')],{'host':_0x7e1e('0xe'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x7e1e('0xc')]));require(_0x7e1e('0xf'))[_0x7e1e('0x10')](socket);function respondWithRpcPromise(_0x1b5549,_0x21b72e,_0x9b2260){return new BPromise(function(_0x23f7e9,_0x562cdb){return client[_0x7e1e('0x11')](_0x1b5549,_0x9b2260)[_0x7e1e('0x12')](function(_0x32440c){logger[_0x7e1e('0x13')]('OpenchannelMessage,\x20%s,\x20%s',_0x21b72e,_0x7e1e('0x14'));logger['debug'](_0x7e1e('0x15'),_0x21b72e,'request\x20sent',JSON['stringify'](_0x32440c));if(_0x32440c['error']){if(_0x32440c[_0x7e1e('0x16')][_0x7e1e('0x17')]===0x1f4){logger[_0x7e1e('0x16')]('OpenchannelMessage,\x20%s,\x20%s',_0x21b72e,_0x32440c['error']['message']);return _0x562cdb(_0x32440c['error']['message']);}logger['error'](_0x7e1e('0x18'),_0x21b72e,_0x32440c[_0x7e1e('0x16')][_0x7e1e('0x19')]);return _0x23f7e9(_0x32440c[_0x7e1e('0x16')]['message']);}else{logger[_0x7e1e('0x13')]('OpenchannelMessage,\x20%s,\x20%s',_0x21b72e,'request\x20sent');_0x23f7e9(_0x32440c[_0x7e1e('0x1a')]['message']);}})[_0x7e1e('0x1b')](function(_0x4a1cbd){logger[_0x7e1e('0x16')]('OpenchannelMessage,\x20%s,\x20%s',_0x21b72e,_0x4a1cbd);_0x562cdb(_0x4a1cbd);});});}exports['CreateOpenchannelMessage']=function(_0x585c90){var _0x5182aa=this;return new Promise(function(_0x2579db,_0xcb3e8e){return db['OpenchannelMessage']['create'](_0x585c90['body'],{'raw':_0x585c90[_0x7e1e('0x1c')]?_0x585c90['options']['raw']===undefined?!![]:![]:!![]})['then'](function(_0x128d3f){logger[_0x7e1e('0x13')]('CreateOpenchannelMessage',_0x585c90);logger[_0x7e1e('0x1d')](_0x7e1e('0x1e'),_0x585c90,JSON['stringify'](_0x128d3f));_0x2579db(_0x128d3f);})['catch'](function(_0x1e95ac){logger[_0x7e1e('0x16')](_0x7e1e('0x1e'),_0x1e95ac['message'],_0x585c90);_0xcb3e8e(_0x5182aa[_0x7e1e('0x16')](0x1f4,_0x1e95ac[_0x7e1e('0x19')]));});});};