cf8c90758f1584091cafef2450cdf384cad9045f
[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 _0xe5a0=['MailQueueReport,\x20%s,\x20%s','request\x20sent','debug','MailQueueReport,\x20%s,\x20%s,\x20%s','error','code','message','info','result','CreateMailQueueReport','MailQueueReport','create','options','raw','stringify','catch','update','body','where','attributes','limit','UpdateMailQueueReport','lodash','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xe5a0,0xee));var _0x0e5a=function(_0x62bb34,_0x2aeffd){_0x62bb34=_0x62bb34-0x0;var _0x6f986a=_0xe5a0[_0x62bb34];return _0x6f986a;};'use strict';var _=require(_0x0e5a('0x0'));var util=require('util');var moment=require(_0x0e5a('0x1'));var BPromise=require(_0x0e5a('0x2'));var rs=require(_0x0e5a('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x0e5a('0x4'))['db'];var utils=require(_0x0e5a('0x5'));var logger=require(_0x0e5a('0x6'))(_0x0e5a('0x7'));var config=require(_0x0e5a('0x8'));var jayson=require(_0x0e5a('0x9'));var client=jayson[_0x0e5a('0xa')][_0x0e5a('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x5dd580,_0x49f190,_0x2fe6aa){return new BPromise(function(_0xf7304c,_0x48073a){return client[_0x0e5a('0xc')](_0x5dd580,_0x2fe6aa)[_0x0e5a('0xd')](function(_0x1c4b6f){logger['info'](_0x0e5a('0xe'),_0x49f190,_0x0e5a('0xf'));logger[_0x0e5a('0x10')](_0x0e5a('0x11'),_0x49f190,_0x0e5a('0xf'),JSON['stringify'](_0x1c4b6f));if(_0x1c4b6f['error']){if(_0x1c4b6f[_0x0e5a('0x12')][_0x0e5a('0x13')]===0x1f4){logger[_0x0e5a('0x12')]('MailQueueReport,\x20%s,\x20%s',_0x49f190,_0x1c4b6f[_0x0e5a('0x12')][_0x0e5a('0x14')]);return _0x48073a(_0x1c4b6f[_0x0e5a('0x12')][_0x0e5a('0x14')]);}logger[_0x0e5a('0x12')](_0x0e5a('0xe'),_0x49f190,_0x1c4b6f[_0x0e5a('0x12')][_0x0e5a('0x14')]);return _0xf7304c(_0x1c4b6f[_0x0e5a('0x12')][_0x0e5a('0x14')]);}else{logger[_0x0e5a('0x15')](_0x0e5a('0xe'),_0x49f190,_0x0e5a('0xf'));_0xf7304c(_0x1c4b6f[_0x0e5a('0x16')][_0x0e5a('0x14')]);}})['catch'](function(_0x5df670){logger[_0x0e5a('0x12')](_0x0e5a('0xe'),_0x49f190,_0x5df670);_0x48073a(_0x5df670);});});}exports[_0x0e5a('0x17')]=function(_0x16b399){var _0x303e89=this;return new Promise(function(_0xce3431,_0x5f4cb4){return db[_0x0e5a('0x18')][_0x0e5a('0x19')](_0x16b399['body'],{'raw':_0x16b399['options']?_0x16b399[_0x0e5a('0x1a')][_0x0e5a('0x1b')]===undefined?!![]:![]:!![]})[_0x0e5a('0xd')](function(_0x8f1899){logger[_0x0e5a('0x15')]('CreateMailQueueReport',_0x16b399);logger['debug'](_0x0e5a('0x17'),_0x16b399,JSON[_0x0e5a('0x1c')](_0x8f1899));_0xce3431(_0x8f1899);})[_0x0e5a('0x1d')](function(_0x108a8c){logger[_0x0e5a('0x12')]('CreateMailQueueReport',_0x108a8c['message'],_0x16b399);_0x5f4cb4(_0x303e89[_0x0e5a('0x12')](0x1f4,_0x108a8c[_0x0e5a('0x14')]));});});};exports['UpdateMailQueueReport']=function(_0x58eef5){var _0x4932df=this;return new Promise(function(_0x870747,_0x2dfe27){return db[_0x0e5a('0x18')][_0x0e5a('0x1e')](_0x58eef5[_0x0e5a('0x1f')],{'raw':_0x58eef5[_0x0e5a('0x1a')]?_0x58eef5[_0x0e5a('0x1a')][_0x0e5a('0x1b')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x58eef5[_0x0e5a('0x1a')]?_0x58eef5[_0x0e5a('0x1a')][_0x0e5a('0x20')]||null:null,'attributes':_0x58eef5[_0x0e5a('0x1a')]?_0x58eef5[_0x0e5a('0x1a')][_0x0e5a('0x21')]||null:null,'limit':_0x58eef5[_0x0e5a('0x1a')]?_0x58eef5['options'][_0x0e5a('0x22')]||null:null})[_0x0e5a('0xd')](function(_0x51a0f8){logger[_0x0e5a('0x15')](_0x0e5a('0x23'),_0x58eef5);logger[_0x0e5a('0x10')]('UpdateMailQueueReport',_0x58eef5,JSON['stringify'](_0x51a0f8));_0x870747(_0x51a0f8);})[_0x0e5a('0x1d')](function(_0x325f24){logger[_0x0e5a('0x12')](_0x0e5a('0x23'),_0x325f24[_0x0e5a('0x14')],_0x58eef5);_0x2dfe27(_0x4932df[_0x0e5a('0x12')](0x1f4,_0x325f24[_0x0e5a('0x14')]));});});};