8dad4231dd53ba7eb86040e6e88b97bdca6376c6
[motion2.git] / server / api / mailQueueReport / mailQueueReport.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 _0x461b=['../../mysqldb','../../config/utils','../../config/logger','rpc','client','http','request','then','info','MailQueueReport,\x20%s,\x20%s','request\x20sent','MailQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','CreateMailQueueReport','MailQueueReport','create','body','options','raw','debug','update','where','attributes','limit','UpdateMailQueueReport','lodash','util','moment','bluebird','randomstring','ioredis'];(function(_0x2ba07c,_0xb58e9d){var _0x4a73fb=function(_0xf1b954){while(--_0xf1b954){_0x2ba07c['push'](_0x2ba07c['shift']());}};_0x4a73fb(++_0xb58e9d);}(_0x461b,0x8a));var _0xb461=function(_0x2641f9,_0x26715f){_0x2641f9=_0x2641f9-0x0;var _0x585741=_0x461b[_0x2641f9];return _0x585741;};'use strict';var _=require(_0xb461('0x0'));var util=require(_0xb461('0x1'));var moment=require(_0xb461('0x2'));var BPromise=require(_0xb461('0x3'));var rs=require(_0xb461('0x4'));var fs=require('fs');var Redis=require(_0xb461('0x5'));var db=require(_0xb461('0x6'))['db'];var utils=require(_0xb461('0x7'));var logger=require(_0xb461('0x8'))(_0xb461('0x9'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0xb461('0xa')][_0xb461('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x23ac64,_0x4ff4aa,_0xe1b037){return new BPromise(function(_0x33c3c1,_0x22b7e6){return client[_0xb461('0xc')](_0x23ac64,_0xe1b037)[_0xb461('0xd')](function(_0x4e744c){logger[_0xb461('0xe')](_0xb461('0xf'),_0x4ff4aa,_0xb461('0x10'));logger['debug'](_0xb461('0x11'),_0x4ff4aa,_0xb461('0x10'),JSON[_0xb461('0x12')](_0x4e744c));if(_0x4e744c['error']){if(_0x4e744c[_0xb461('0x13')][_0xb461('0x14')]===0x1f4){logger['error']('MailQueueReport,\x20%s,\x20%s',_0x4ff4aa,_0x4e744c[_0xb461('0x13')][_0xb461('0x15')]);return _0x22b7e6(_0x4e744c[_0xb461('0x13')]['message']);}logger[_0xb461('0x13')](_0xb461('0xf'),_0x4ff4aa,_0x4e744c[_0xb461('0x13')][_0xb461('0x15')]);return _0x33c3c1(_0x4e744c[_0xb461('0x13')]['message']);}else{logger[_0xb461('0xe')](_0xb461('0xf'),_0x4ff4aa,_0xb461('0x10'));_0x33c3c1(_0x4e744c[_0xb461('0x16')][_0xb461('0x15')]);}})[_0xb461('0x17')](function(_0x265787){logger['error']('MailQueueReport,\x20%s,\x20%s',_0x4ff4aa,_0x265787);_0x22b7e6(_0x265787);});});}exports[_0xb461('0x18')]=function(_0x2a3e03){var _0x322ccc=this;return new Promise(function(_0xb84a00,_0x3400ca){return db[_0xb461('0x19')][_0xb461('0x1a')](_0x2a3e03[_0xb461('0x1b')],{'raw':_0x2a3e03[_0xb461('0x1c')]?_0x2a3e03['options'][_0xb461('0x1d')]===undefined?!![]:![]:!![]})[_0xb461('0xd')](function(_0x109229){logger['info'](_0xb461('0x18'),_0x2a3e03);logger[_0xb461('0x1e')](_0xb461('0x18'),_0x2a3e03,JSON['stringify'](_0x109229));_0xb84a00(_0x109229);})[_0xb461('0x17')](function(_0x1748f8){logger[_0xb461('0x13')](_0xb461('0x18'),_0x1748f8['message'],_0x2a3e03);_0x3400ca(_0x322ccc['error'](0x1f4,_0x1748f8[_0xb461('0x15')]));});});};exports['UpdateMailQueueReport']=function(_0x33b6fa){var _0x5d1bfb=this;return new Promise(function(_0x5a7430,_0x8fe163){return db[_0xb461('0x19')][_0xb461('0x1f')](_0x33b6fa[_0xb461('0x1b')],{'raw':_0x33b6fa[_0xb461('0x1c')]?_0x33b6fa[_0xb461('0x1c')][_0xb461('0x1d')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x33b6fa['options']?_0x33b6fa[_0xb461('0x1c')][_0xb461('0x20')]||null:null,'attributes':_0x33b6fa[_0xb461('0x1c')]?_0x33b6fa[_0xb461('0x1c')][_0xb461('0x21')]||null:null,'limit':_0x33b6fa[_0xb461('0x1c')]?_0x33b6fa[_0xb461('0x1c')][_0xb461('0x22')]||null:null})[_0xb461('0xd')](function(_0xddb27a){logger[_0xb461('0xe')](_0xb461('0x23'),_0x33b6fa);logger[_0xb461('0x1e')](_0xb461('0x23'),_0x33b6fa,JSON['stringify'](_0xddb27a));_0x5a7430(_0xddb27a);})['catch'](function(_0x34750b){logger[_0xb461('0x13')](_0xb461('0x23'),_0x34750b[_0xb461('0x15')],_0x33b6fa);_0x8fe163(_0x5d1bfb['error'](0x1f4,_0x34750b[_0xb461('0x15')]));});});};