41bd48d96428b9ac45ef1b80b2d916f6d6d6a1db
[motion2.git] / server / api / chatApplication / chatApplication.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 _0xaab7=['moment','bluebird','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','ChatApplication,\x20%s,\x20%s','debug','request\x20sent','error','message','result','util'];(function(_0x53de45,_0x33096d){var _0x2267a3=function(_0x2e79e1){while(--_0x2e79e1){_0x53de45['push'](_0x53de45['shift']());}};_0x2267a3(++_0x33096d);}(_0xaab7,0x77));var _0x7aab=function(_0x464a77,_0x468333){_0x464a77=_0x464a77-0x0;var _0x1c27af=_0xaab7[_0x464a77];return _0x1c27af;};'use strict';var _=require('lodash');var util=require(_0x7aab('0x0'));var moment=require(_0x7aab('0x1'));var BPromise=require(_0x7aab('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x7aab('0x3'))['db'];var utils=require(_0x7aab('0x4'));var logger=require(_0x7aab('0x5'))(_0x7aab('0x6'));var config=require(_0x7aab('0x7'));var jayson=require(_0x7aab('0x8'));var client=jayson[_0x7aab('0x9')][_0x7aab('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x3ab447,_0x54e8e2,_0x249582){return new BPromise(function(_0x3046f5,_0x12fcce){return client[_0x7aab('0xb')](_0x3ab447,_0x249582)[_0x7aab('0xc')](function(_0x4de2bc){logger[_0x7aab('0xd')](_0x7aab('0xe'),_0x54e8e2,'request\x20sent');logger[_0x7aab('0xf')]('ChatApplication,\x20%s,\x20%s,\x20%s',_0x54e8e2,_0x7aab('0x10'),JSON['stringify'](_0x4de2bc));if(_0x4de2bc[_0x7aab('0x11')]){if(_0x4de2bc[_0x7aab('0x11')]['code']===0x1f4){logger['error']('ChatApplication,\x20%s,\x20%s',_0x54e8e2,_0x4de2bc[_0x7aab('0x11')][_0x7aab('0x12')]);return _0x12fcce(_0x4de2bc[_0x7aab('0x11')][_0x7aab('0x12')]);}logger[_0x7aab('0x11')](_0x7aab('0xe'),_0x54e8e2,_0x4de2bc[_0x7aab('0x11')][_0x7aab('0x12')]);return _0x3046f5(_0x4de2bc[_0x7aab('0x11')][_0x7aab('0x12')]);}else{logger[_0x7aab('0xd')](_0x7aab('0xe'),_0x54e8e2,_0x7aab('0x10'));_0x3046f5(_0x4de2bc[_0x7aab('0x13')]['message']);}})['catch'](function(_0x3eb92b){logger[_0x7aab('0x11')]('ChatApplication,\x20%s,\x20%s',_0x54e8e2,_0x3eb92b);_0x12fcce(_0x3eb92b);});});}