Built motion from commit (unavailable).|2.5.28
[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 _0xee20=['../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','request','then','info','request\x20sent','MailQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','code','MailQueueReport,\x20%s,\x20%s','message','result','catch','MailQueueReport','create','body','options','raw','CreateMailQueueReport','debug','UpdateMailQueueReport','update','where','attributes','limit','lodash','util','bluebird','randomstring'];(function(_0x44353d,_0x267761){var _0x93dd90=function(_0x218cc1){while(--_0x218cc1){_0x44353d['push'](_0x44353d['shift']());}};_0x93dd90(++_0x267761);}(_0xee20,0x15a));var _0x0ee2=function(_0x43c6fc,_0xd63f13){_0x43c6fc=_0x43c6fc-0x0;var _0x1a4912=_0xee20[_0x43c6fc];return _0x1a4912;};'use strict';var _=require(_0x0ee2('0x0'));var util=require(_0x0ee2('0x1'));var moment=require('moment');var BPromise=require(_0x0ee2('0x2'));var rs=require(_0x0ee2('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x0ee2('0x4'))['db'];var utils=require(_0x0ee2('0x5'));var logger=require(_0x0ee2('0x6'))('rpc');var config=require(_0x0ee2('0x7'));var jayson=require(_0x0ee2('0x8'));var client=jayson[_0x0ee2('0x9')][_0x0ee2('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x4a7c48,_0x1eec3a,_0x114961){return new BPromise(function(_0x42a7de,_0x57fa8b){return client[_0x0ee2('0xb')](_0x4a7c48,_0x114961)[_0x0ee2('0xc')](function(_0x161010){logger[_0x0ee2('0xd')]('MailQueueReport,\x20%s,\x20%s',_0x1eec3a,_0x0ee2('0xe'));logger['debug'](_0x0ee2('0xf'),_0x1eec3a,'request\x20sent',JSON[_0x0ee2('0x10')](_0x161010));if(_0x161010['error']){if(_0x161010[_0x0ee2('0x11')][_0x0ee2('0x12')]===0x1f4){logger[_0x0ee2('0x11')](_0x0ee2('0x13'),_0x1eec3a,_0x161010[_0x0ee2('0x11')]['message']);return _0x57fa8b(_0x161010[_0x0ee2('0x11')]['message']);}logger[_0x0ee2('0x11')](_0x0ee2('0x13'),_0x1eec3a,_0x161010[_0x0ee2('0x11')][_0x0ee2('0x14')]);return _0x42a7de(_0x161010[_0x0ee2('0x11')][_0x0ee2('0x14')]);}else{logger[_0x0ee2('0xd')](_0x0ee2('0x13'),_0x1eec3a,_0x0ee2('0xe'));_0x42a7de(_0x161010[_0x0ee2('0x15')][_0x0ee2('0x14')]);}})[_0x0ee2('0x16')](function(_0x4c2209){logger['error'](_0x0ee2('0x13'),_0x1eec3a,_0x4c2209);_0x57fa8b(_0x4c2209);});});}exports['CreateMailQueueReport']=function(_0x5984a1){var _0xb2d707=this;return new Promise(function(_0x3fa1b1,_0x4be06e){return db[_0x0ee2('0x17')][_0x0ee2('0x18')](_0x5984a1[_0x0ee2('0x19')],{'raw':_0x5984a1['options']?_0x5984a1[_0x0ee2('0x1a')][_0x0ee2('0x1b')]===undefined?!![]:![]:!![]})[_0x0ee2('0xc')](function(_0x51528a){logger['info'](_0x0ee2('0x1c'),_0x5984a1);logger[_0x0ee2('0x1d')](_0x0ee2('0x1c'),_0x5984a1,JSON[_0x0ee2('0x10')](_0x51528a));_0x3fa1b1(_0x51528a);})[_0x0ee2('0x16')](function(_0x55fc84){logger[_0x0ee2('0x11')]('CreateMailQueueReport',_0x55fc84['message'],_0x5984a1);_0x4be06e(_0xb2d707[_0x0ee2('0x11')](0x1f4,_0x55fc84[_0x0ee2('0x14')]));});});};exports[_0x0ee2('0x1e')]=function(_0x35df2f){var _0x407c5c=this;return new Promise(function(_0xfc350a,_0x4397fa){return db[_0x0ee2('0x17')][_0x0ee2('0x1f')](_0x35df2f[_0x0ee2('0x19')],{'raw':_0x35df2f[_0x0ee2('0x1a')]?_0x35df2f['options'][_0x0ee2('0x1b')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x35df2f[_0x0ee2('0x1a')]?_0x35df2f['options'][_0x0ee2('0x20')]||null:null,'attributes':_0x35df2f[_0x0ee2('0x1a')]?_0x35df2f[_0x0ee2('0x1a')][_0x0ee2('0x21')]||null:null,'limit':_0x35df2f['options']?_0x35df2f[_0x0ee2('0x1a')][_0x0ee2('0x22')]||null:null})[_0x0ee2('0xc')](function(_0x178c35){logger[_0x0ee2('0xd')](_0x0ee2('0x1e'),_0x35df2f);logger[_0x0ee2('0x1d')]('UpdateMailQueueReport',_0x35df2f,JSON[_0x0ee2('0x10')](_0x178c35));_0xfc350a(_0x178c35);})[_0x0ee2('0x16')](function(_0x4e2724){logger[_0x0ee2('0x11')](_0x0ee2('0x1e'),_0x4e2724['message'],_0x35df2f);_0x4397fa(_0x407c5c[_0x0ee2('0x11')](0x1f4,_0x4e2724[_0x0ee2('0x14')]));});});};