83233b1d997617bc5093316955ffd0a34dc7815d
[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 _0xd99b=['CreateMailQueueReport','MailQueueReport','create','body','options','raw','UpdateMailQueueReport','update','where','limit','lodash','util','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','request','then','info','request\x20sent','debug','MailQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','MailQueueReport,\x20%s,\x20%s','message','result','catch'];(function(_0x5ac1e5,_0x4b5012){var _0x1bccc6=function(_0x102562){while(--_0x102562){_0x5ac1e5['push'](_0x5ac1e5['shift']());}};_0x1bccc6(++_0x4b5012);}(_0xd99b,0x196));var _0xbd99=function(_0x57e5db,_0x3d6ace){_0x57e5db=_0x57e5db-0x0;var _0x2c1f43=_0xd99b[_0x57e5db];return _0x2c1f43;};'use strict';var _=require(_0xbd99('0x0'));var util=require(_0xbd99('0x1'));var moment=require('moment');var BPromise=require(_0xbd99('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xbd99('0x3'));var db=require(_0xbd99('0x4'))['db'];var utils=require(_0xbd99('0x5'));var logger=require(_0xbd99('0x6'))('rpc');var config=require(_0xbd99('0x7'));var jayson=require(_0xbd99('0x8'));var client=jayson[_0xbd99('0x9')][_0xbd99('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x146413,_0x19211e,_0x516104){return new BPromise(function(_0x29f8fa,_0x8c9809){return client[_0xbd99('0xb')](_0x146413,_0x516104)[_0xbd99('0xc')](function(_0x133881){logger[_0xbd99('0xd')]('MailQueueReport,\x20%s,\x20%s',_0x19211e,_0xbd99('0xe'));logger[_0xbd99('0xf')](_0xbd99('0x10'),_0x19211e,_0xbd99('0xe'),JSON[_0xbd99('0x11')](_0x133881));if(_0x133881[_0xbd99('0x12')]){if(_0x133881[_0xbd99('0x12')]['code']===0x1f4){logger['error'](_0xbd99('0x13'),_0x19211e,_0x133881['error']['message']);return _0x8c9809(_0x133881[_0xbd99('0x12')]['message']);}logger[_0xbd99('0x12')](_0xbd99('0x13'),_0x19211e,_0x133881[_0xbd99('0x12')][_0xbd99('0x14')]);return _0x29f8fa(_0x133881['error'][_0xbd99('0x14')]);}else{logger[_0xbd99('0xd')](_0xbd99('0x13'),_0x19211e,_0xbd99('0xe'));_0x29f8fa(_0x133881[_0xbd99('0x15')]['message']);}})[_0xbd99('0x16')](function(_0xf188ae){logger['error'](_0xbd99('0x13'),_0x19211e,_0xf188ae);_0x8c9809(_0xf188ae);});});}exports[_0xbd99('0x17')]=function(_0x2784f0){var _0x142acd=this;return new Promise(function(_0x5e8666,_0x10bc3b){return db[_0xbd99('0x18')][_0xbd99('0x19')](_0x2784f0[_0xbd99('0x1a')],{'raw':_0x2784f0[_0xbd99('0x1b')]?_0x2784f0[_0xbd99('0x1b')][_0xbd99('0x1c')]===undefined?!![]:![]:!![]})[_0xbd99('0xc')](function(_0x30cb92){logger['info'](_0xbd99('0x17'),_0x2784f0);logger[_0xbd99('0xf')](_0xbd99('0x17'),_0x2784f0,JSON[_0xbd99('0x11')](_0x30cb92));_0x5e8666(_0x30cb92);})[_0xbd99('0x16')](function(_0x3645da){logger[_0xbd99('0x12')]('CreateMailQueueReport',_0x3645da[_0xbd99('0x14')],_0x2784f0);_0x10bc3b(_0x142acd[_0xbd99('0x12')](0x1f4,_0x3645da['message']));});});};exports[_0xbd99('0x1d')]=function(_0x4f2972){var _0x25bb68=this;return new Promise(function(_0x2cdcc3,_0x2a4b9e){return db[_0xbd99('0x18')][_0xbd99('0x1e')](_0x4f2972[_0xbd99('0x1a')],{'raw':_0x4f2972['options']?_0x4f2972[_0xbd99('0x1b')][_0xbd99('0x1c')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x4f2972[_0xbd99('0x1b')]?_0x4f2972['options'][_0xbd99('0x1f')]||null:null,'attributes':_0x4f2972[_0xbd99('0x1b')]?_0x4f2972['options']['attributes']||null:null,'limit':_0x4f2972[_0xbd99('0x1b')]?_0x4f2972[_0xbd99('0x1b')][_0xbd99('0x20')]||null:null})[_0xbd99('0xc')](function(_0x1243be){logger[_0xbd99('0xd')](_0xbd99('0x1d'),_0x4f2972);logger['debug'](_0xbd99('0x1d'),_0x4f2972,JSON[_0xbd99('0x11')](_0x1243be));_0x2cdcc3(_0x1243be);})[_0xbd99('0x16')](function(_0x947e31){logger[_0xbd99('0x12')](_0xbd99('0x1d'),_0x947e31[_0xbd99('0x14')],_0x4f2972);_0x2a4b9e(_0x25bb68[_0xbd99('0x12')](0x1f4,_0x947e31[_0xbd99('0x14')]));});});};