Built motion from commit ae138b72.|2.6.28
[motion2.git] / server / api / whatsappQueueReport / whatsappQueueReport.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 _0x0fd8=['http','request','info','debug','WhatsappQueueReport,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','WhatsappQueueReport,\x20%s,\x20%s','message','result','catch','CreateWhatsappQueueReport','create','raw','then','UpdateWhatsappQueueReport','WhatsappQueueReport','update','options','attributes','limit','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise'];(function(_0x5f5159,_0x7311ad){var _0x214e93=function(_0x560ee6){while(--_0x560ee6){_0x5f5159['push'](_0x5f5159['shift']());}};_0x214e93(++_0x7311ad);}(_0x0fd8,0x127));var _0x80fd=function(_0x53ccf2,_0x13cb67){_0x53ccf2=_0x53ccf2-0x0;var _0x5a2964=_0x0fd8[_0x53ccf2];return _0x5a2964;};'use strict';var _=require(_0x80fd('0x0'));var util=require(_0x80fd('0x1'));var moment=require(_0x80fd('0x2'));var BPromise=require('bluebird');var rs=require(_0x80fd('0x3'));var fs=require('fs');var Redis=require(_0x80fd('0x4'));var db=require(_0x80fd('0x5'))['db'];var utils=require(_0x80fd('0x6'));var logger=require(_0x80fd('0x7'))(_0x80fd('0x8'));var config=require(_0x80fd('0x9'));var jayson=require(_0x80fd('0xa'));var client=jayson['client'][_0x80fd('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x50536b,_0x296dbd,_0x24b983){return new BPromise(function(_0x465c30,_0x4c7710){return client[_0x80fd('0xc')](_0x50536b,_0x24b983)['then'](function(_0x4ceca6){logger[_0x80fd('0xd')]('WhatsappQueueReport,\x20%s,\x20%s',_0x296dbd,'request\x20sent');logger[_0x80fd('0xe')](_0x80fd('0xf'),_0x296dbd,_0x80fd('0x10'),JSON[_0x80fd('0x11')](_0x4ceca6));if(_0x4ceca6[_0x80fd('0x12')]){if(_0x4ceca6[_0x80fd('0x12')][_0x80fd('0x13')]===0x1f4){logger[_0x80fd('0x12')](_0x80fd('0x14'),_0x296dbd,_0x4ceca6[_0x80fd('0x12')]['message']);return _0x4c7710(_0x4ceca6[_0x80fd('0x12')]['message']);}logger[_0x80fd('0x12')](_0x80fd('0x14'),_0x296dbd,_0x4ceca6[_0x80fd('0x12')][_0x80fd('0x15')]);return _0x465c30(_0x4ceca6[_0x80fd('0x12')]['message']);}else{logger[_0x80fd('0xd')](_0x80fd('0x14'),_0x296dbd,_0x80fd('0x10'));_0x465c30(_0x4ceca6[_0x80fd('0x16')][_0x80fd('0x15')]);}})[_0x80fd('0x17')](function(_0x40dd93){logger[_0x80fd('0x12')](_0x80fd('0x14'),_0x296dbd,_0x40dd93);_0x4c7710(_0x40dd93);});});}exports[_0x80fd('0x18')]=function(_0x110dc4){var _0x4cc263=this;return new Promise(function(_0x14b304,_0x5e50c8){return db['WhatsappQueueReport'][_0x80fd('0x19')](_0x110dc4['body'],{'raw':_0x110dc4['options']?_0x110dc4['options'][_0x80fd('0x1a')]===undefined?!![]:![]:!![]})[_0x80fd('0x1b')](function(_0x5a2d65){logger['info']('CreateWhatsappQueueReport',_0x110dc4);logger[_0x80fd('0xe')]('CreateWhatsappQueueReport',_0x110dc4,JSON[_0x80fd('0x11')](_0x5a2d65));_0x14b304(_0x5a2d65);})[_0x80fd('0x17')](function(_0x5308ed){logger[_0x80fd('0x12')](_0x80fd('0x18'),_0x5308ed[_0x80fd('0x15')],_0x110dc4);_0x5e50c8(_0x4cc263[_0x80fd('0x12')](0x1f4,_0x5308ed[_0x80fd('0x15')]));});});};exports[_0x80fd('0x1c')]=function(_0x4e808b){var _0x581c57=this;return new Promise(function(_0x1f9a27,_0x294635){return db[_0x80fd('0x1d')][_0x80fd('0x1e')](_0x4e808b['body'],{'raw':_0x4e808b['options']?_0x4e808b[_0x80fd('0x1f')][_0x80fd('0x1a')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x4e808b[_0x80fd('0x1f')]?_0x4e808b[_0x80fd('0x1f')]['where']||null:null,'attributes':_0x4e808b[_0x80fd('0x1f')]?_0x4e808b[_0x80fd('0x1f')][_0x80fd('0x20')]||null:null,'limit':_0x4e808b['options']?_0x4e808b[_0x80fd('0x1f')][_0x80fd('0x21')]||null:null})[_0x80fd('0x1b')](function(_0x53411d){logger[_0x80fd('0xd')]('UpdateWhatsappQueueReport',_0x4e808b);logger['debug'](_0x80fd('0x1c'),_0x4e808b,JSON['stringify'](_0x53411d));_0x1f9a27(_0x53411d);})[_0x80fd('0x17')](function(_0x2b0147){logger['error'](_0x80fd('0x1c'),_0x2b0147[_0x80fd('0x15')],_0x4e808b);_0x294635(_0x581c57[_0x80fd('0x12')](0x1f4,_0x2b0147[_0x80fd('0x15')]));});});};