d607e184fb717a6e11f94ad88235064d7db8a2ac
[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 _0x74df=['ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','request\x20sent','debug','MailQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','code','MailQueueReport,\x20%s,\x20%s','message','info','result','catch','CreateMailQueueReport','body','options','raw','UpdateMailQueueReport','update','where','attributes','limit','lodash','util','moment','bluebird','randomstring'];(function(_0x46e363,_0x45d7e2){var _0x3fb059=function(_0x5e6274){while(--_0x5e6274){_0x46e363['push'](_0x46e363['shift']());}};_0x3fb059(++_0x45d7e2);}(_0x74df,0xaa));var _0xf74d=function(_0x92cb0c,_0x2911a1){_0x92cb0c=_0x92cb0c-0x0;var _0x3e36d1=_0x74df[_0x92cb0c];return _0x3e36d1;};'use strict';var _=require(_0xf74d('0x0'));var util=require(_0xf74d('0x1'));var moment=require(_0xf74d('0x2'));var BPromise=require(_0xf74d('0x3'));var rs=require(_0xf74d('0x4'));var fs=require('fs');var Redis=require(_0xf74d('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0xf74d('0x6'));var logger=require(_0xf74d('0x7'))(_0xf74d('0x8'));var config=require(_0xf74d('0x9'));var jayson=require(_0xf74d('0xa'));var client=jayson[_0xf74d('0xb')][_0xf74d('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x1f18e2,_0x3526dc,_0x463dcc){return new BPromise(function(_0x190f45,_0x1324b4){return client[_0xf74d('0xd')](_0x1f18e2,_0x463dcc)[_0xf74d('0xe')](function(_0xcb0939){logger['info']('MailQueueReport,\x20%s,\x20%s',_0x3526dc,_0xf74d('0xf'));logger[_0xf74d('0x10')](_0xf74d('0x11'),_0x3526dc,_0xf74d('0xf'),JSON[_0xf74d('0x12')](_0xcb0939));if(_0xcb0939['error']){if(_0xcb0939[_0xf74d('0x13')][_0xf74d('0x14')]===0x1f4){logger[_0xf74d('0x13')](_0xf74d('0x15'),_0x3526dc,_0xcb0939[_0xf74d('0x13')][_0xf74d('0x16')]);return _0x1324b4(_0xcb0939[_0xf74d('0x13')]['message']);}logger['error'](_0xf74d('0x15'),_0x3526dc,_0xcb0939[_0xf74d('0x13')]['message']);return _0x190f45(_0xcb0939['error'][_0xf74d('0x16')]);}else{logger[_0xf74d('0x17')](_0xf74d('0x15'),_0x3526dc,_0xf74d('0xf'));_0x190f45(_0xcb0939[_0xf74d('0x18')][_0xf74d('0x16')]);}})[_0xf74d('0x19')](function(_0x1ae81b){logger[_0xf74d('0x13')](_0xf74d('0x15'),_0x3526dc,_0x1ae81b);_0x1324b4(_0x1ae81b);});});}exports[_0xf74d('0x1a')]=function(_0xead69e){var _0x33539e=this;return new Promise(function(_0x3d6b7f,_0x18809e){return db['MailQueueReport']['create'](_0xead69e[_0xf74d('0x1b')],{'raw':_0xead69e[_0xf74d('0x1c')]?_0xead69e[_0xf74d('0x1c')][_0xf74d('0x1d')]===undefined?!![]:![]:!![]})[_0xf74d('0xe')](function(_0x40cf9e){logger[_0xf74d('0x17')](_0xf74d('0x1a'),_0xead69e);logger[_0xf74d('0x10')](_0xf74d('0x1a'),_0xead69e,JSON[_0xf74d('0x12')](_0x40cf9e));_0x3d6b7f(_0x40cf9e);})[_0xf74d('0x19')](function(_0x34f96f){logger[_0xf74d('0x13')](_0xf74d('0x1a'),_0x34f96f['message'],_0xead69e);_0x18809e(_0x33539e[_0xf74d('0x13')](0x1f4,_0x34f96f[_0xf74d('0x16')]));});});};exports[_0xf74d('0x1e')]=function(_0x2154b7){var _0x3e1ca6=this;return new Promise(function(_0x3394f3,_0x4e2ef9){return db['MailQueueReport'][_0xf74d('0x1f')](_0x2154b7[_0xf74d('0x1b')],{'raw':_0x2154b7['options']?_0x2154b7['options'][_0xf74d('0x1d')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x2154b7[_0xf74d('0x1c')]?_0x2154b7[_0xf74d('0x1c')][_0xf74d('0x20')]||null:null,'attributes':_0x2154b7[_0xf74d('0x1c')]?_0x2154b7[_0xf74d('0x1c')][_0xf74d('0x21')]||null:null,'limit':_0x2154b7[_0xf74d('0x1c')]?_0x2154b7[_0xf74d('0x1c')][_0xf74d('0x22')]||null:null})[_0xf74d('0xe')](function(_0x5a90b8){logger[_0xf74d('0x17')](_0xf74d('0x1e'),_0x2154b7);logger[_0xf74d('0x10')]('UpdateMailQueueReport',_0x2154b7,JSON[_0xf74d('0x12')](_0x5a90b8));_0x3394f3(_0x5a90b8);})[_0xf74d('0x19')](function(_0xbb216d){logger['error'](_0xf74d('0x1e'),_0xbb216d[_0xf74d('0x16')],_0x2154b7);_0x4e2ef9(_0x3e1ca6['error'](0x1f4,_0xbb216d[_0xf74d('0x16')]));});});};