Built motion from commit e0fa946e.|2.6.5
[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 _0x8411=['bluebird','ioredis','../../config/utils','rpc','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./smsQueue.socket','register','request','SmsQueue,\x20%s,\x20%s','request\x20sent','debug','stringify','code','error','message','info','result','catch','GetSmsQueue','findAll','options','raw','where','limit','include','attributes','map','SmsQueue','find','model','then','ShowSmsQueue','util'];(function(_0x38d9a9,_0x9afda6){var _0x2e4214=function(_0x51c54e){while(--_0x51c54e){_0x38d9a9['push'](_0x38d9a9['shift']());}};_0x2e4214(++_0x9afda6);}(_0x8411,0x185));var _0x1841=function(_0x4a47f4,_0x3a3961){_0x4a47f4=_0x4a47f4-0x0;var _0x5753a3=_0x8411[_0x4a47f4];return _0x5753a3;};'use strict';var _=require('lodash');var util=require(_0x1841('0x0'));var moment=require('moment');var BPromise=require(_0x1841('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x1841('0x2'));var db=require('../../mysqldb')['db'];var utils=require(_0x1841('0x3'));var logger=require('../../config/logger')(_0x1841('0x4'));var config=require('../../config/environment');var jayson=require(_0x1841('0x5'));var client=jayson[_0x1841('0x6')][_0x1841('0x7')]({'port':0x232a});config[_0x1841('0x8')]=_[_0x1841('0x9')](config[_0x1841('0x8')],{'host':_0x1841('0xa'),'port':0x18eb});var socket=require(_0x1841('0xb'))(new Redis(config[_0x1841('0x8')]));require(_0x1841('0xc'))[_0x1841('0xd')](socket);function respondWithRpcPromise(_0x568bf3,_0x979d79,_0x576fb9){return new BPromise(function(_0xe03a49,_0x5ca162){return client[_0x1841('0xe')](_0x568bf3,_0x576fb9)['then'](function(_0x183160){logger['info'](_0x1841('0xf'),_0x979d79,_0x1841('0x10'));logger[_0x1841('0x11')]('SmsQueue,\x20%s,\x20%s,\x20%s',_0x979d79,_0x1841('0x10'),JSON[_0x1841('0x12')](_0x183160));if(_0x183160['error']){if(_0x183160['error'][_0x1841('0x13')]===0x1f4){logger[_0x1841('0x14')](_0x1841('0xf'),_0x979d79,_0x183160[_0x1841('0x14')][_0x1841('0x15')]);return _0x5ca162(_0x183160[_0x1841('0x14')][_0x1841('0x15')]);}logger[_0x1841('0x14')](_0x1841('0xf'),_0x979d79,_0x183160['error']['message']);return _0xe03a49(_0x183160[_0x1841('0x14')]['message']);}else{logger[_0x1841('0x16')](_0x1841('0xf'),_0x979d79,_0x1841('0x10'));_0xe03a49(_0x183160[_0x1841('0x17')][_0x1841('0x15')]);}})[_0x1841('0x18')](function(_0x1ffb0d){logger['error'](_0x1841('0xf'),_0x979d79,_0x1ffb0d);_0x5ca162(_0x1ffb0d);});});}exports[_0x1841('0x19')]=function(_0x2f54c4){var _0x4a8570=this;return new Promise(function(_0x18a1e3,_0x4b7d09){return db['SmsQueue'][_0x1841('0x1a')]({'raw':_0x2f54c4[_0x1841('0x1b')]?_0x2f54c4[_0x1841('0x1b')][_0x1841('0x1c')]===undefined?!![]:![]:!![],'where':_0x2f54c4['options']?_0x2f54c4[_0x1841('0x1b')][_0x1841('0x1d')]||null:null,'attributes':_0x2f54c4['options']?_0x2f54c4[_0x1841('0x1b')]['attributes']||null:null,'limit':_0x2f54c4['options']?_0x2f54c4[_0x1841('0x1b')][_0x1841('0x1e')]||null:null,'include':_0x2f54c4[_0x1841('0x1b')]?_0x2f54c4[_0x1841('0x1b')][_0x1841('0x1f')]?_['map'](_0x2f54c4[_0x1841('0x1b')][_0x1841('0x1f')],function(_0x4f5089){return{'model':db[_0x4f5089['model']],'as':_0x4f5089['as'],'attributes':_0x4f5089[_0x1841('0x20')],'include':_0x4f5089[_0x1841('0x1f')]?_[_0x1841('0x21')](_0x4f5089[_0x1841('0x1f')],function(_0x43beeb){return{'model':db[_0x43beeb['model']],'as':_0x43beeb['as'],'attributes':_0x43beeb[_0x1841('0x20')],'include':_0x43beeb[_0x1841('0x1f')]?_[_0x1841('0x21')](_0x43beeb[_0x1841('0x1f')],function(_0x32e5f4){return{'model':db[_0x32e5f4['model']],'as':_0x32e5f4['as'],'attributes':_0x32e5f4[_0x1841('0x20')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x4ee844){logger[_0x1841('0x16')]('GetSmsQueue',_0x2f54c4);logger[_0x1841('0x11')](_0x1841('0x19'),_0x2f54c4,JSON[_0x1841('0x12')](_0x4ee844));_0x18a1e3(_0x4ee844);})[_0x1841('0x18')](function(_0x30e0b5){logger['error']('GetSmsQueue',_0x30e0b5['message'],_0x2f54c4);_0x4b7d09(_0x4a8570[_0x1841('0x14')](0x1f4,_0x30e0b5[_0x1841('0x15')]));});});};exports['ShowSmsQueue']=function(_0x5933c7){var _0x13c6bb=this;return new Promise(function(_0x465791,_0x2be1e5){return db[_0x1841('0x22')][_0x1841('0x23')]({'raw':_0x5933c7[_0x1841('0x1b')]?_0x5933c7['options'][_0x1841('0x1c')]===undefined?!![]:![]:!![],'where':_0x5933c7[_0x1841('0x1b')]?_0x5933c7['options']['where']||null:null,'attributes':_0x5933c7['options']?_0x5933c7[_0x1841('0x1b')][_0x1841('0x20')]||null:null,'include':_0x5933c7[_0x1841('0x1b')]?_0x5933c7[_0x1841('0x1b')][_0x1841('0x1f')]?_[_0x1841('0x21')](_0x5933c7[_0x1841('0x1b')][_0x1841('0x1f')],function(_0xd8aebd){return{'model':db[_0xd8aebd['model']],'as':_0xd8aebd['as'],'attributes':_0xd8aebd[_0x1841('0x20')],'include':_0xd8aebd['include']?_[_0x1841('0x21')](_0xd8aebd[_0x1841('0x1f')],function(_0x462f71){return{'model':db[_0x462f71[_0x1841('0x24')]],'as':_0x462f71['as'],'attributes':_0x462f71[_0x1841('0x20')],'include':_0x462f71[_0x1841('0x1f')]?_[_0x1841('0x21')](_0x462f71[_0x1841('0x1f')],function(_0x2b5683){return{'model':db[_0x2b5683[_0x1841('0x24')]],'as':_0x2b5683['as'],'attributes':_0x2b5683[_0x1841('0x20')]};}):[]};}):[]};}):[]:[]})[_0x1841('0x25')](function(_0x2d0235){logger[_0x1841('0x16')](_0x1841('0x26'),_0x5933c7);logger[_0x1841('0x11')]('ShowSmsQueue',_0x5933c7,JSON[_0x1841('0x12')](_0x2d0235));_0x465791(_0x2d0235);})[_0x1841('0x18')](function(_0x366f8b){logger[_0x1841('0x14')](_0x1841('0x26'),_0x366f8b[_0x1841('0x15')],_0x5933c7);_0x2be1e5(_0x13c6bb[_0x1841('0x14')](0x1f4,_0x366f8b[_0x1841('0x15')]));});});};