Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / chatInternalMessage / chatInternalMessage.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 _0x8b2d=['localhost','socket.io-emitter','register','request','ChatInternalMessage,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','info','result','catch','moment','randomstring','ioredis','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','redis','defaults'];(function(_0x33deb7,_0x25181a){var _0x3dfeeb=function(_0x310393){while(--_0x310393){_0x33deb7['push'](_0x33deb7['shift']());}};_0x3dfeeb(++_0x25181a);}(_0x8b2d,0xe5));var _0xd8b2=function(_0x2d4521,_0x8d98b6){_0x2d4521=_0x2d4521-0x0;var _0x5d765f=_0x8b2d[_0x2d4521];return _0x5d765f;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0xd8b2('0x0'));var BPromise=require('bluebird');var rs=require(_0xd8b2('0x1'));var fs=require('fs');var Redis=require(_0xd8b2('0x2'));var db=require('../../mysqldb')['db'];var utils=require(_0xd8b2('0x3'));var logger=require(_0xd8b2('0x4'))('rpc');var config=require(_0xd8b2('0x5'));var jayson=require(_0xd8b2('0x6'));var client=jayson[_0xd8b2('0x7')][_0xd8b2('0x8')]({'port':0x232a});config[_0xd8b2('0x9')]=_[_0xd8b2('0xa')](config[_0xd8b2('0x9')],{'host':_0xd8b2('0xb'),'port':0x18eb});var socket=require(_0xd8b2('0xc'))(new Redis(config[_0xd8b2('0x9')]));require('./chatInternalMessage.socket')[_0xd8b2('0xd')](socket);function respondWithRpcPromise(_0x47acb6,_0x2236aa,_0x27c2c2){return new BPromise(function(_0xba39d5,_0x1fd1a7){return client[_0xd8b2('0xe')](_0x47acb6,_0x27c2c2)['then'](function(_0x53298a){logger['info'](_0xd8b2('0xf'),_0x2236aa,_0xd8b2('0x10'));logger[_0xd8b2('0x11')]('ChatInternalMessage,\x20%s,\x20%s,\x20%s',_0x2236aa,_0xd8b2('0x10'),JSON[_0xd8b2('0x12')](_0x53298a));if(_0x53298a[_0xd8b2('0x13')]){if(_0x53298a[_0xd8b2('0x13')]['code']===0x1f4){logger[_0xd8b2('0x13')]('ChatInternalMessage,\x20%s,\x20%s',_0x2236aa,_0x53298a['error'][_0xd8b2('0x14')]);return _0x1fd1a7(_0x53298a[_0xd8b2('0x13')][_0xd8b2('0x14')]);}logger[_0xd8b2('0x13')](_0xd8b2('0xf'),_0x2236aa,_0x53298a[_0xd8b2('0x13')][_0xd8b2('0x14')]);return _0xba39d5(_0x53298a['error']['message']);}else{logger[_0xd8b2('0x15')]('ChatInternalMessage,\x20%s,\x20%s',_0x2236aa,_0xd8b2('0x10'));_0xba39d5(_0x53298a[_0xd8b2('0x16')][_0xd8b2('0x14')]);}})[_0xd8b2('0x17')](function(_0x2ccbfe){logger['error'](_0xd8b2('0xf'),_0x2236aa,_0x2ccbfe);_0x1fd1a7(_0x2ccbfe);});});}