Built motion from commit 9d1906d1.|2.5.40
[motion2.git] / server / api / smsQueue / smsQueue.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 _0xb5b3=['raw','where','attributes','limit','include','model','debug','stringify','ShowSmsQueue','find','map','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','./smsQueue.socket','register','then','info','SmsQueue,\x20%s,\x20%s','request\x20sent','code','error','message','catch','GetSmsQueue','SmsQueue','findAll','options'];(function(_0x596fea,_0x5d7c58){var _0x1b9187=function(_0x59c6ec){while(--_0x59c6ec){_0x596fea['push'](_0x596fea['shift']());}};_0x1b9187(++_0x5d7c58);}(_0xb5b3,0x15b));var _0x3b5b=function(_0xcc32ac,_0x57c211){_0xcc32ac=_0xcc32ac-0x0;var _0x557786=_0xb5b3[_0xcc32ac];return _0x557786;};'use strict';var _=require(_0x3b5b('0x0'));var util=require(_0x3b5b('0x1'));var moment=require(_0x3b5b('0x2'));var BPromise=require(_0x3b5b('0x3'));var rs=require(_0x3b5b('0x4'));var fs=require('fs');var Redis=require(_0x3b5b('0x5'));var db=require(_0x3b5b('0x6'))['db'];var utils=require(_0x3b5b('0x7'));var logger=require(_0x3b5b('0x8'))(_0x3b5b('0x9'));var config=require(_0x3b5b('0xa'));var jayson=require(_0x3b5b('0xb'));var client=jayson[_0x3b5b('0xc')][_0x3b5b('0xd')]({'port':0x232a});config[_0x3b5b('0xe')]=_[_0x3b5b('0xf')](config[_0x3b5b('0xe')],{'host':_0x3b5b('0x10'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x3b5b('0xe')]));require(_0x3b5b('0x11'))[_0x3b5b('0x12')](socket);function respondWithRpcPromise(_0x47a12b,_0x31970a,_0x482858){return new BPromise(function(_0x34bd30,_0x408e0f){return client['request'](_0x47a12b,_0x482858)[_0x3b5b('0x13')](function(_0x3b887b){logger[_0x3b5b('0x14')](_0x3b5b('0x15'),_0x31970a,_0x3b5b('0x16'));logger['debug']('SmsQueue,\x20%s,\x20%s,\x20%s',_0x31970a,'request\x20sent',JSON['stringify'](_0x3b887b));if(_0x3b887b['error']){if(_0x3b887b['error'][_0x3b5b('0x17')]===0x1f4){logger[_0x3b5b('0x18')]('SmsQueue,\x20%s,\x20%s',_0x31970a,_0x3b887b[_0x3b5b('0x18')]['message']);return _0x408e0f(_0x3b887b[_0x3b5b('0x18')][_0x3b5b('0x19')]);}logger[_0x3b5b('0x18')](_0x3b5b('0x15'),_0x31970a,_0x3b887b[_0x3b5b('0x18')]['message']);return _0x34bd30(_0x3b887b['error'][_0x3b5b('0x19')]);}else{logger[_0x3b5b('0x14')](_0x3b5b('0x15'),_0x31970a,'request\x20sent');_0x34bd30(_0x3b887b['result']['message']);}})[_0x3b5b('0x1a')](function(_0x414aed){logger['error'](_0x3b5b('0x15'),_0x31970a,_0x414aed);_0x408e0f(_0x414aed);});});}exports[_0x3b5b('0x1b')]=function(_0x33a0b5){var _0x3b82a5=this;return new Promise(function(_0x44affd,_0x45ae66){return db[_0x3b5b('0x1c')][_0x3b5b('0x1d')]({'raw':_0x33a0b5[_0x3b5b('0x1e')]?_0x33a0b5[_0x3b5b('0x1e')][_0x3b5b('0x1f')]===undefined?!![]:![]:!![],'where':_0x33a0b5[_0x3b5b('0x1e')]?_0x33a0b5['options'][_0x3b5b('0x20')]||null:null,'attributes':_0x33a0b5[_0x3b5b('0x1e')]?_0x33a0b5['options'][_0x3b5b('0x21')]||null:null,'limit':_0x33a0b5[_0x3b5b('0x1e')]?_0x33a0b5['options'][_0x3b5b('0x22')]||null:null,'include':_0x33a0b5[_0x3b5b('0x1e')]?_0x33a0b5[_0x3b5b('0x1e')]['include']?_['map'](_0x33a0b5[_0x3b5b('0x1e')][_0x3b5b('0x23')],function(_0x36260e){return{'model':db[_0x36260e[_0x3b5b('0x24')]],'as':_0x36260e['as'],'attributes':_0x36260e[_0x3b5b('0x21')],'include':_0x36260e['include']?_['map'](_0x36260e['include'],function(_0x476fc0){return{'model':db[_0x476fc0[_0x3b5b('0x24')]],'as':_0x476fc0['as'],'attributes':_0x476fc0[_0x3b5b('0x21')],'include':_0x476fc0[_0x3b5b('0x23')]?_['map'](_0x476fc0[_0x3b5b('0x23')],function(_0x12822d){return{'model':db[_0x12822d[_0x3b5b('0x24')]],'as':_0x12822d['as'],'attributes':_0x12822d['attributes']};}):[]};}):[]};}):[]:[]})[_0x3b5b('0x13')](function(_0x1ab66f){logger[_0x3b5b('0x14')](_0x3b5b('0x1b'),_0x33a0b5);logger[_0x3b5b('0x25')](_0x3b5b('0x1b'),_0x33a0b5,JSON[_0x3b5b('0x26')](_0x1ab66f));_0x44affd(_0x1ab66f);})[_0x3b5b('0x1a')](function(_0x4086db){logger['error'](_0x3b5b('0x1b'),_0x4086db[_0x3b5b('0x19')],_0x33a0b5);_0x45ae66(_0x3b82a5[_0x3b5b('0x18')](0x1f4,_0x4086db['message']));});});};exports[_0x3b5b('0x27')]=function(_0x4fecbd){var _0x47217a=this;return new Promise(function(_0x49b187,_0x10ec1b){return db[_0x3b5b('0x1c')][_0x3b5b('0x28')]({'raw':_0x4fecbd['options']?_0x4fecbd[_0x3b5b('0x1e')][_0x3b5b('0x1f')]===undefined?!![]:![]:!![],'where':_0x4fecbd[_0x3b5b('0x1e')]?_0x4fecbd[_0x3b5b('0x1e')][_0x3b5b('0x20')]||null:null,'attributes':_0x4fecbd['options']?_0x4fecbd[_0x3b5b('0x1e')][_0x3b5b('0x21')]||null:null,'include':_0x4fecbd['options']?_0x4fecbd[_0x3b5b('0x1e')]['include']?_[_0x3b5b('0x29')](_0x4fecbd[_0x3b5b('0x1e')][_0x3b5b('0x23')],function(_0x5129e0){return{'model':db[_0x5129e0[_0x3b5b('0x24')]],'as':_0x5129e0['as'],'attributes':_0x5129e0[_0x3b5b('0x21')],'include':_0x5129e0[_0x3b5b('0x23')]?_[_0x3b5b('0x29')](_0x5129e0[_0x3b5b('0x23')],function(_0x2838b0){return{'model':db[_0x2838b0[_0x3b5b('0x24')]],'as':_0x2838b0['as'],'attributes':_0x2838b0[_0x3b5b('0x21')],'include':_0x2838b0['include']?_[_0x3b5b('0x29')](_0x2838b0[_0x3b5b('0x23')],function(_0x56755b){return{'model':db[_0x56755b['model']],'as':_0x56755b['as'],'attributes':_0x56755b['attributes']};}):[]};}):[]};}):[]:[]})[_0x3b5b('0x13')](function(_0x582362){logger['info']('ShowSmsQueue',_0x4fecbd);logger['debug']('ShowSmsQueue',_0x4fecbd,JSON['stringify'](_0x582362));_0x49b187(_0x582362);})['catch'](function(_0x3987b7){logger['error'](_0x3b5b('0x27'),_0x3987b7[_0x3b5b('0x19')],_0x4fecbd);_0x10ec1b(_0x47217a[_0x3b5b('0x18')](0x1f4,_0x3987b7['message']));});});};