Built motion from commit 47436d59.|2.6.7
[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 _0xe313=['defaults','localhost','./chatInternalMessage.socket','request','then','info','ChatInternalMessage,\x20%s,\x20%s','debug','ChatInternalMessage,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','message','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','redis'];(function(_0x2972ad,_0x200e62){var _0x2021cb=function(_0x2ef2c5){while(--_0x2ef2c5){_0x2972ad['push'](_0x2972ad['shift']());}};_0x2021cb(++_0x200e62);}(_0xe313,0xe5));var _0x3e31=function(_0x3ef68e,_0xc40085){_0x3ef68e=_0x3ef68e-0x0;var _0x3485c7=_0xe313[_0x3ef68e];return _0x3485c7;};'use strict';var _=require(_0x3e31('0x0'));var util=require(_0x3e31('0x1'));var moment=require(_0x3e31('0x2'));var BPromise=require(_0x3e31('0x3'));var rs=require(_0x3e31('0x4'));var fs=require('fs');var Redis=require(_0x3e31('0x5'));var db=require(_0x3e31('0x6'))['db'];var utils=require(_0x3e31('0x7'));var logger=require(_0x3e31('0x8'))(_0x3e31('0x9'));var config=require('../../config/environment');var jayson=require(_0x3e31('0xa'));var client=jayson[_0x3e31('0xb')][_0x3e31('0xc')]({'port':0x232a});config[_0x3e31('0xd')]=_[_0x3e31('0xe')](config['redis'],{'host':_0x3e31('0xf'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x3e31('0xd')]));require(_0x3e31('0x10'))['register'](socket);function respondWithRpcPromise(_0x2e1afb,_0x4dd40b,_0x37c045){return new BPromise(function(_0x1bf3ab,_0x2cba0f){return client[_0x3e31('0x11')](_0x2e1afb,_0x37c045)[_0x3e31('0x12')](function(_0x26bf2d){logger[_0x3e31('0x13')](_0x3e31('0x14'),_0x4dd40b,'request\x20sent');logger[_0x3e31('0x15')](_0x3e31('0x16'),_0x4dd40b,_0x3e31('0x17'),JSON[_0x3e31('0x18')](_0x26bf2d));if(_0x26bf2d[_0x3e31('0x19')]){if(_0x26bf2d['error']['code']===0x1f4){logger['error'](_0x3e31('0x14'),_0x4dd40b,_0x26bf2d[_0x3e31('0x19')][_0x3e31('0x1a')]);return _0x2cba0f(_0x26bf2d[_0x3e31('0x19')][_0x3e31('0x1a')]);}logger[_0x3e31('0x19')]('ChatInternalMessage,\x20%s,\x20%s',_0x4dd40b,_0x26bf2d[_0x3e31('0x19')][_0x3e31('0x1a')]);return _0x1bf3ab(_0x26bf2d['error'][_0x3e31('0x1a')]);}else{logger['info']('ChatInternalMessage,\x20%s,\x20%s',_0x4dd40b,_0x3e31('0x17'));_0x1bf3ab(_0x26bf2d['result']['message']);}})['catch'](function(_0x247346){logger[_0x3e31('0x19')](_0x3e31('0x14'),_0x4dd40b,_0x247346);_0x2cba0f(_0x247346);});});}