2186f305c0c1a0b171a692c2e997c6976bee86bb
[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 _0xfaf2=['defaults','localhost','socket.io-emitter','register','request','info','OpenchannelMessage,\x20%s,\x20%s','debug','request\x20sent','stringify','error','code','message','result','catch','CreateOpenchannelMessage','OpenchannelMessage','body','raw','then','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','redis'];(function(_0x56d41b,_0x55f5cc){var _0x1ec566=function(_0x20fc19){while(--_0x20fc19){_0x56d41b['push'](_0x56d41b['shift']());}};_0x1ec566(++_0x55f5cc);}(_0xfaf2,0x169));var _0x2faf=function(_0x3d8e2a,_0x4e76c4){_0x3d8e2a=_0x3d8e2a-0x0;var _0x49a950=_0xfaf2[_0x3d8e2a];return _0x49a950;};'use strict';var _=require(_0x2faf('0x0'));var util=require(_0x2faf('0x1'));var moment=require(_0x2faf('0x2'));var BPromise=require(_0x2faf('0x3'));var rs=require(_0x2faf('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x2faf('0x5'))['db'];var utils=require(_0x2faf('0x6'));var logger=require(_0x2faf('0x7'))(_0x2faf('0x8'));var config=require(_0x2faf('0x9'));var jayson=require('jayson/promise');var client=jayson['client']['http']({'port':0x232a});config[_0x2faf('0xa')]=_[_0x2faf('0xb')](config[_0x2faf('0xa')],{'host':_0x2faf('0xc'),'port':0x18eb});var socket=require(_0x2faf('0xd'))(new Redis(config['redis']));require('./openchannelMessage.socket')[_0x2faf('0xe')](socket);function respondWithRpcPromise(_0x262959,_0x4ca336,_0x4f041a){return new BPromise(function(_0x3ec8cc,_0x3fa4b0){return client[_0x2faf('0xf')](_0x262959,_0x4f041a)['then'](function(_0x515eb6){logger[_0x2faf('0x10')](_0x2faf('0x11'),_0x4ca336,'request\x20sent');logger[_0x2faf('0x12')]('OpenchannelMessage,\x20%s,\x20%s,\x20%s',_0x4ca336,_0x2faf('0x13'),JSON[_0x2faf('0x14')](_0x515eb6));if(_0x515eb6[_0x2faf('0x15')]){if(_0x515eb6[_0x2faf('0x15')][_0x2faf('0x16')]===0x1f4){logger[_0x2faf('0x15')]('OpenchannelMessage,\x20%s,\x20%s',_0x4ca336,_0x515eb6[_0x2faf('0x15')][_0x2faf('0x17')]);return _0x3fa4b0(_0x515eb6['error'][_0x2faf('0x17')]);}logger[_0x2faf('0x15')](_0x2faf('0x11'),_0x4ca336,_0x515eb6[_0x2faf('0x15')]['message']);return _0x3ec8cc(_0x515eb6[_0x2faf('0x15')][_0x2faf('0x17')]);}else{logger[_0x2faf('0x10')](_0x2faf('0x11'),_0x4ca336,'request\x20sent');_0x3ec8cc(_0x515eb6[_0x2faf('0x18')][_0x2faf('0x17')]);}})[_0x2faf('0x19')](function(_0x2b226b){logger[_0x2faf('0x15')](_0x2faf('0x11'),_0x4ca336,_0x2b226b);_0x3fa4b0(_0x2b226b);});});}exports[_0x2faf('0x1a')]=function(_0x5e4009){var _0x48627f=this;return new Promise(function(_0x4bf409,_0x219f13){return db[_0x2faf('0x1b')]['create'](_0x5e4009[_0x2faf('0x1c')],{'raw':_0x5e4009['options']?_0x5e4009['options'][_0x2faf('0x1d')]===undefined?!![]:![]:!![]})[_0x2faf('0x1e')](function(_0x5d8cb7){logger[_0x2faf('0x10')](_0x2faf('0x1a'),_0x5e4009);logger[_0x2faf('0x12')](_0x2faf('0x1a'),_0x5e4009,JSON[_0x2faf('0x14')](_0x5d8cb7));_0x4bf409(_0x5d8cb7);})[_0x2faf('0x19')](function(_0x1d6649){logger[_0x2faf('0x15')](_0x2faf('0x1a'),_0x1d6649[_0x2faf('0x17')],_0x5e4009);_0x219f13(_0x48627f[_0x2faf('0x15')](0x1f4,_0x1d6649[_0x2faf('0x17')]));});});};