Built motion from commit c738b9ac.|2.6.25
[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 _0xb2e8=['http','redis','defaults','socket.io-emitter','register','request\x20sent','debug','ChatInternalMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','ChatInternalMessage,\x20%s,\x20%s','message','info','result','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc'];(function(_0x1d6b9a,_0x5d34db){var _0x283671=function(_0x876b2f){while(--_0x876b2f){_0x1d6b9a['push'](_0x1d6b9a['shift']());}};_0x283671(++_0x5d34db);}(_0xb2e8,0x1ef));var _0x8b2e=function(_0x40c9b4,_0x623264){_0x40c9b4=_0x40c9b4-0x0;var _0x5ac02c=_0xb2e8[_0x40c9b4];return _0x5ac02c;};'use strict';var _=require(_0x8b2e('0x0'));var util=require(_0x8b2e('0x1'));var moment=require(_0x8b2e('0x2'));var BPromise=require(_0x8b2e('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x8b2e('0x4'));var db=require(_0x8b2e('0x5'))['db'];var utils=require(_0x8b2e('0x6'));var logger=require(_0x8b2e('0x7'))(_0x8b2e('0x8'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson['client'][_0x8b2e('0x9')]({'port':0x232a});config[_0x8b2e('0xa')]=_[_0x8b2e('0xb')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x8b2e('0xc'))(new Redis(config[_0x8b2e('0xa')]));require('./chatInternalMessage.socket')[_0x8b2e('0xd')](socket);function respondWithRpcPromise(_0x515d7b,_0x206ace,_0xfcbd12){return new BPromise(function(_0x20cf6b,_0x3c5444){return client['request'](_0x515d7b,_0xfcbd12)['then'](function(_0x471a36){logger['info']('ChatInternalMessage,\x20%s,\x20%s',_0x206ace,_0x8b2e('0xe'));logger[_0x8b2e('0xf')](_0x8b2e('0x10'),_0x206ace,_0x8b2e('0xe'),JSON[_0x8b2e('0x11')](_0x471a36));if(_0x471a36[_0x8b2e('0x12')]){if(_0x471a36['error'][_0x8b2e('0x13')]===0x1f4){logger[_0x8b2e('0x12')](_0x8b2e('0x14'),_0x206ace,_0x471a36[_0x8b2e('0x12')][_0x8b2e('0x15')]);return _0x3c5444(_0x471a36[_0x8b2e('0x12')]['message']);}logger[_0x8b2e('0x12')](_0x8b2e('0x14'),_0x206ace,_0x471a36[_0x8b2e('0x12')]['message']);return _0x20cf6b(_0x471a36['error']['message']);}else{logger[_0x8b2e('0x16')](_0x8b2e('0x14'),_0x206ace,'request\x20sent');_0x20cf6b(_0x471a36[_0x8b2e('0x17')]['message']);}})['catch'](function(_0x4af5ca){logger[_0x8b2e('0x12')](_0x8b2e('0x14'),_0x206ace,_0x4af5ca);_0x3c5444(_0x4af5ca);});});}