Built motion from commit (unavailable).|2.0.78
[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 _0x5fc3=['../../config/logger','../../config/environment','jayson/promise','client','localhost','register','request','info','request\x20sent','debug','stringify','code','OpenchannelMessage,\x20%s,\x20%s','error','message','result','catch','CreateOpenchannelMessage','OpenchannelMessage','body','options','raw','then','lodash','util','bluebird','randomstring','../../mysqldb','../../config/utils'];(function(_0x1f0f2f,_0x587f0f){var _0x22c04e=function(_0x124b91){while(--_0x124b91){_0x1f0f2f['push'](_0x1f0f2f['shift']());}};_0x22c04e(++_0x587f0f);}(_0x5fc3,0xa8));var _0x35fc=function(_0x2ee790,_0x5a8661){_0x2ee790=_0x2ee790-0x0;var _0x5a54a5=_0x5fc3[_0x2ee790];return _0x5a54a5;};'use strict';var _=require(_0x35fc('0x0'));var util=require(_0x35fc('0x1'));var moment=require('moment');var BPromise=require(_0x35fc('0x2'));var rs=require(_0x35fc('0x3'));var fs=require('fs');var db=require(_0x35fc('0x4'))['db'];var utils=require(_0x35fc('0x5'));var logger=require(_0x35fc('0x6'))('rpc');var config=require(_0x35fc('0x7'));var jayson=require(_0x35fc('0x8'));var client=jayson[_0x35fc('0x9')]['http']({'port':0x232a});var socket=require('socket.io-emitter')({'host':_0x35fc('0xa'),'port':0x18eb});require('./openchannelMessage.socket')[_0x35fc('0xb')](socket);function respondWithRpcPromise(_0x27524f,_0xc72d93,_0x1e5f90){return new BPromise(function(_0x34ff19,_0xf9d3a6){return client[_0x35fc('0xc')](_0x27524f,_0x1e5f90)['then'](function(_0x1083a9){logger[_0x35fc('0xd')]('OpenchannelMessage,\x20%s,\x20%s',_0xc72d93,_0x35fc('0xe'));logger[_0x35fc('0xf')]('OpenchannelMessage,\x20%s,\x20%s,\x20%s',_0xc72d93,_0x35fc('0xe'),JSON[_0x35fc('0x10')](_0x1083a9));if(_0x1083a9['error']){if(_0x1083a9['error'][_0x35fc('0x11')]===0x1f4){logger['error'](_0x35fc('0x12'),_0xc72d93,_0x1083a9[_0x35fc('0x13')][_0x35fc('0x14')]);return _0xf9d3a6(_0x1083a9[_0x35fc('0x13')][_0x35fc('0x14')]);}logger['error']('OpenchannelMessage,\x20%s,\x20%s',_0xc72d93,_0x1083a9['error']['message']);return _0x34ff19(_0x1083a9[_0x35fc('0x13')][_0x35fc('0x14')]);}else{logger[_0x35fc('0xd')](_0x35fc('0x12'),_0xc72d93,_0x35fc('0xe'));_0x34ff19(_0x1083a9[_0x35fc('0x15')]['message']);}})[_0x35fc('0x16')](function(_0x45c8b7){logger['error'](_0x35fc('0x12'),_0xc72d93,_0x45c8b7);_0xf9d3a6(_0x45c8b7);});});}exports[_0x35fc('0x17')]=function(_0x2e513b){var _0x5f56c6=this;return new Promise(function(_0x1a86e9,_0x3c58ea){return db[_0x35fc('0x18')]['create'](_0x2e513b[_0x35fc('0x19')],{'raw':_0x2e513b[_0x35fc('0x1a')]?_0x2e513b[_0x35fc('0x1a')][_0x35fc('0x1b')]===undefined?!![]:![]:!![]})[_0x35fc('0x1c')](function(_0x21f1a9){logger[_0x35fc('0xd')](_0x35fc('0x17'),_0x2e513b);logger[_0x35fc('0xf')](_0x35fc('0x17'),_0x2e513b,JSON['stringify'](_0x21f1a9));_0x1a86e9(_0x21f1a9);})[_0x35fc('0x16')](function(_0xd5399f){logger[_0x35fc('0x13')](_0x35fc('0x17'),_0xd5399f[_0x35fc('0x14')],_0x2e513b);_0x3c58ea(_0x5f56c6['error'](0x1f4,_0xd5399f[_0x35fc('0x14')]));});});};