Built motion from commit (unavailable).|2.5.3
[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 _0x12b4=['options','raw','limit','include','map','model','attributes','ShowSmsQueue','find','where','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','jayson/promise','client','redis','defaults','localhost','./smsQueue.socket','register','request','then','info','SmsQueue,\x20%s,\x20%s','request\x20sent','debug','SmsQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetSmsQueue','SmsQueue','findAll'];(function(_0x4d43dd,_0x157523){var _0x5d171f=function(_0x404677){while(--_0x404677){_0x4d43dd['push'](_0x4d43dd['shift']());}};_0x5d171f(++_0x157523);}(_0x12b4,0xae));var _0x412b=function(_0x502c7d,_0x2f1285){_0x502c7d=_0x502c7d-0x0;var _0x30b7ed=_0x12b4[_0x502c7d];return _0x30b7ed;};'use strict';var _=require(_0x412b('0x0'));var util=require(_0x412b('0x1'));var moment=require(_0x412b('0x2'));var BPromise=require('bluebird');var rs=require(_0x412b('0x3'));var fs=require('fs');var Redis=require(_0x412b('0x4'));var db=require(_0x412b('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x412b('0x6'))(_0x412b('0x7'));var config=require('../../config/environment');var jayson=require(_0x412b('0x8'));var client=jayson[_0x412b('0x9')]['http']({'port':0x232a});config[_0x412b('0xa')]=_[_0x412b('0xb')](config[_0x412b('0xa')],{'host':_0x412b('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x412b('0xa')]));require(_0x412b('0xd'))[_0x412b('0xe')](socket);function respondWithRpcPromise(_0x24f2b5,_0x8c933f,_0x5122e9){return new BPromise(function(_0x3eb68e,_0x1248b3){return client[_0x412b('0xf')](_0x24f2b5,_0x5122e9)[_0x412b('0x10')](function(_0xff29aa){logger[_0x412b('0x11')](_0x412b('0x12'),_0x8c933f,_0x412b('0x13'));logger[_0x412b('0x14')](_0x412b('0x15'),_0x8c933f,_0x412b('0x13'),JSON[_0x412b('0x16')](_0xff29aa));if(_0xff29aa[_0x412b('0x17')]){if(_0xff29aa[_0x412b('0x17')][_0x412b('0x18')]===0x1f4){logger['error'](_0x412b('0x12'),_0x8c933f,_0xff29aa['error'][_0x412b('0x19')]);return _0x1248b3(_0xff29aa[_0x412b('0x17')]['message']);}logger['error'](_0x412b('0x12'),_0x8c933f,_0xff29aa[_0x412b('0x17')][_0x412b('0x19')]);return _0x3eb68e(_0xff29aa[_0x412b('0x17')]['message']);}else{logger[_0x412b('0x11')](_0x412b('0x12'),_0x8c933f,_0x412b('0x13'));_0x3eb68e(_0xff29aa[_0x412b('0x1a')][_0x412b('0x19')]);}})[_0x412b('0x1b')](function(_0x3d6031){logger[_0x412b('0x17')](_0x412b('0x12'),_0x8c933f,_0x3d6031);_0x1248b3(_0x3d6031);});});}exports[_0x412b('0x1c')]=function(_0x4e27d1){var _0x2b192a=this;return new Promise(function(_0x4aba17,_0x222dc7){return db[_0x412b('0x1d')][_0x412b('0x1e')]({'raw':_0x4e27d1[_0x412b('0x1f')]?_0x4e27d1[_0x412b('0x1f')][_0x412b('0x20')]===undefined?!![]:![]:!![],'where':_0x4e27d1[_0x412b('0x1f')]?_0x4e27d1[_0x412b('0x1f')]['where']||null:null,'attributes':_0x4e27d1[_0x412b('0x1f')]?_0x4e27d1[_0x412b('0x1f')]['attributes']||null:null,'limit':_0x4e27d1[_0x412b('0x1f')]?_0x4e27d1[_0x412b('0x1f')][_0x412b('0x21')]||null:null,'include':_0x4e27d1[_0x412b('0x1f')]?_0x4e27d1[_0x412b('0x1f')][_0x412b('0x22')]?_[_0x412b('0x23')](_0x4e27d1['options'][_0x412b('0x22')],function(_0x29d2d2){return{'model':db[_0x29d2d2[_0x412b('0x24')]],'as':_0x29d2d2['as'],'attributes':_0x29d2d2[_0x412b('0x25')],'include':_0x29d2d2[_0x412b('0x22')]?_[_0x412b('0x23')](_0x29d2d2['include'],function(_0xa1c2bb){return{'model':db[_0xa1c2bb[_0x412b('0x24')]],'as':_0xa1c2bb['as'],'attributes':_0xa1c2bb[_0x412b('0x25')],'include':_0xa1c2bb['include']?_[_0x412b('0x23')](_0xa1c2bb[_0x412b('0x22')],function(_0x2d5316){return{'model':db[_0x2d5316[_0x412b('0x24')]],'as':_0x2d5316['as'],'attributes':_0x2d5316[_0x412b('0x25')]};}):[]};}):[]};}):[]:[]})[_0x412b('0x10')](function(_0x353057){logger['info'](_0x412b('0x1c'),_0x4e27d1);logger[_0x412b('0x14')](_0x412b('0x1c'),_0x4e27d1,JSON[_0x412b('0x16')](_0x353057));_0x4aba17(_0x353057);})[_0x412b('0x1b')](function(_0x9c767b){logger[_0x412b('0x17')](_0x412b('0x1c'),_0x9c767b['message'],_0x4e27d1);_0x222dc7(_0x2b192a['error'](0x1f4,_0x9c767b[_0x412b('0x19')]));});});};exports[_0x412b('0x26')]=function(_0x53ea80){var _0x31d8d0=this;return new Promise(function(_0x4b7509,_0x2c1b9e){return db[_0x412b('0x1d')][_0x412b('0x27')]({'raw':_0x53ea80[_0x412b('0x1f')]?_0x53ea80[_0x412b('0x1f')]['raw']===undefined?!![]:![]:!![],'where':_0x53ea80[_0x412b('0x1f')]?_0x53ea80[_0x412b('0x1f')][_0x412b('0x28')]||null:null,'attributes':_0x53ea80['options']?_0x53ea80[_0x412b('0x1f')][_0x412b('0x25')]||null:null,'include':_0x53ea80[_0x412b('0x1f')]?_0x53ea80[_0x412b('0x1f')][_0x412b('0x22')]?_[_0x412b('0x23')](_0x53ea80[_0x412b('0x1f')]['include'],function(_0x3ad22f){return{'model':db[_0x3ad22f[_0x412b('0x24')]],'as':_0x3ad22f['as'],'attributes':_0x3ad22f[_0x412b('0x25')],'include':_0x3ad22f[_0x412b('0x22')]?_['map'](_0x3ad22f['include'],function(_0x4e8d67){return{'model':db[_0x4e8d67[_0x412b('0x24')]],'as':_0x4e8d67['as'],'attributes':_0x4e8d67['attributes'],'include':_0x4e8d67[_0x412b('0x22')]?_[_0x412b('0x23')](_0x4e8d67['include'],function(_0x120208){return{'model':db[_0x120208[_0x412b('0x24')]],'as':_0x120208['as'],'attributes':_0x120208[_0x412b('0x25')]};}):[]};}):[]};}):[]:[]})[_0x412b('0x10')](function(_0x388d78){logger[_0x412b('0x11')]('ShowSmsQueue',_0x53ea80);logger['debug'](_0x412b('0x26'),_0x53ea80,JSON['stringify'](_0x388d78));_0x4b7509(_0x388d78);})[_0x412b('0x1b')](function(_0x257830){logger[_0x412b('0x17')](_0x412b('0x26'),_0x257830['message'],_0x53ea80);_0x2c1b9e(_0x31d8d0[_0x412b('0x17')](0x1f4,_0x257830[_0x412b('0x19')]));});});};