4e8b19924ffc620587c64bdbcaa34b11d15a01dc
[motion2.git] / server / api / chatQueueReport / chatQueueReport.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 _0xf568=['then','debug','stringify','catch','UpdateChatQueueReport','body','where','attributes','lodash','moment','randomstring','ioredis','../../mysqldb','../../config/logger','../../config/environment','jayson/promise','ChatQueueReport,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','ChatQueueReport,\x20%s,\x20%s','message','info','result','CreateChatQueueReport','ChatQueueReport','create','options','raw'];(function(_0x48f8ad,_0x1c9185){var _0x40747e=function(_0x4dbbbf){while(--_0x4dbbbf){_0x48f8ad['push'](_0x48f8ad['shift']());}};_0x40747e(++_0x1c9185);}(_0xf568,0x12a));var _0x8f56=function(_0x1611c5,_0x407403){_0x1611c5=_0x1611c5-0x0;var _0x43172c=_0xf568[_0x1611c5];return _0x43172c;};'use strict';var _=require(_0x8f56('0x0'));var util=require('util');var moment=require(_0x8f56('0x1'));var BPromise=require('bluebird');var rs=require(_0x8f56('0x2'));var fs=require('fs');var Redis=require(_0x8f56('0x3'));var db=require(_0x8f56('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0x8f56('0x5'))('rpc');var config=require(_0x8f56('0x6'));var jayson=require(_0x8f56('0x7'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x199b07,_0x1a0520,_0x3ff5b4){return new BPromise(function(_0x100dc2,_0x158e6b){return client['request'](_0x199b07,_0x3ff5b4)['then'](function(_0xd1b0ea){logger['info']('ChatQueueReport,\x20%s,\x20%s',_0x1a0520,'request\x20sent');logger['debug'](_0x8f56('0x8'),_0x1a0520,_0x8f56('0x9'),JSON['stringify'](_0xd1b0ea));if(_0xd1b0ea[_0x8f56('0xa')]){if(_0xd1b0ea['error'][_0x8f56('0xb')]===0x1f4){logger[_0x8f56('0xa')](_0x8f56('0xc'),_0x1a0520,_0xd1b0ea[_0x8f56('0xa')]['message']);return _0x158e6b(_0xd1b0ea[_0x8f56('0xa')][_0x8f56('0xd')]);}logger[_0x8f56('0xa')]('ChatQueueReport,\x20%s,\x20%s',_0x1a0520,_0xd1b0ea[_0x8f56('0xa')][_0x8f56('0xd')]);return _0x100dc2(_0xd1b0ea[_0x8f56('0xa')]['message']);}else{logger[_0x8f56('0xe')]('ChatQueueReport,\x20%s,\x20%s',_0x1a0520,_0x8f56('0x9'));_0x100dc2(_0xd1b0ea[_0x8f56('0xf')][_0x8f56('0xd')]);}})['catch'](function(_0x15f8ba){logger['error']('ChatQueueReport,\x20%s,\x20%s',_0x1a0520,_0x15f8ba);_0x158e6b(_0x15f8ba);});});}exports[_0x8f56('0x10')]=function(_0x1a6457){var _0x4b3f50=this;return new Promise(function(_0x26d4d0,_0x359d07){return db[_0x8f56('0x11')][_0x8f56('0x12')](_0x1a6457['body'],{'raw':_0x1a6457[_0x8f56('0x13')]?_0x1a6457[_0x8f56('0x13')][_0x8f56('0x14')]===undefined?!![]:![]:!![]})[_0x8f56('0x15')](function(_0x31803e){logger['info']('CreateChatQueueReport',_0x1a6457);logger[_0x8f56('0x16')]('CreateChatQueueReport',_0x1a6457,JSON[_0x8f56('0x17')](_0x31803e));_0x26d4d0(_0x31803e);})[_0x8f56('0x18')](function(_0x50a6c1){logger[_0x8f56('0xa')](_0x8f56('0x10'),_0x50a6c1[_0x8f56('0xd')],_0x1a6457);_0x359d07(_0x4b3f50[_0x8f56('0xa')](0x1f4,_0x50a6c1[_0x8f56('0xd')]));});});};exports[_0x8f56('0x19')]=function(_0x118125){var _0x5639bb=this;return new Promise(function(_0x4b9d86,_0x1adc8a){return db[_0x8f56('0x11')]['update'](_0x118125[_0x8f56('0x1a')],{'raw':_0x118125[_0x8f56('0x13')]?_0x118125[_0x8f56('0x13')][_0x8f56('0x14')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x118125[_0x8f56('0x13')]?_0x118125[_0x8f56('0x13')][_0x8f56('0x1b')]||null:null,'attributes':_0x118125[_0x8f56('0x13')]?_0x118125[_0x8f56('0x13')][_0x8f56('0x1c')]||null:null,'limit':_0x118125[_0x8f56('0x13')]?_0x118125['options']['limit']||null:null})[_0x8f56('0x15')](function(_0xd824a8){logger['info'](_0x8f56('0x19'),_0x118125);logger[_0x8f56('0x16')](_0x8f56('0x19'),_0x118125,JSON[_0x8f56('0x17')](_0xd824a8));_0x4b9d86(_0xd824a8);})[_0x8f56('0x18')](function(_0x2e987f){logger[_0x8f56('0xa')]('UpdateChatQueueReport',_0x2e987f['message'],_0x118125);_0x1adc8a(_0x5639bb['error'](0x1f4,_0x2e987f[_0x8f56('0xd')]));});});};