Built motion from commit (unavailable).|2.5.30
[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 _0xa26e=['ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','redis','socket.io-emitter','./smsQueue.socket','register','request','then','info','request\x20sent','debug','stringify','error','code','SmsQueue,\x20%s,\x20%s','message','catch','GetSmsQueue','SmsQueue','findAll','options','raw','attributes','limit','include','map','model','ShowSmsQueue','find','moment','bluebird','randomstring'];(function(_0x50ac66,_0x4525a0){var _0x252290=function(_0x342377){while(--_0x342377){_0x50ac66['push'](_0x50ac66['shift']());}};_0x252290(++_0x4525a0);}(_0xa26e,0x194));var _0xea26=function(_0x1d23ac,_0x514da6){_0x1d23ac=_0x1d23ac-0x0;var _0x915d17=_0xa26e[_0x1d23ac];return _0x915d17;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0xea26('0x0'));var BPromise=require(_0xea26('0x1'));var rs=require(_0xea26('0x2'));var fs=require('fs');var Redis=require(_0xea26('0x3'));var db=require(_0xea26('0x4'))['db'];var utils=require(_0xea26('0x5'));var logger=require(_0xea26('0x6'))(_0xea26('0x7'));var config=require('../../config/environment');var jayson=require(_0xea26('0x8'));var client=jayson[_0xea26('0x9')]['http']({'port':0x232a});config[_0xea26('0xa')]=_['defaults'](config[_0xea26('0xa')],{'host':'localhost','port':0x18eb});var socket=require(_0xea26('0xb'))(new Redis(config['redis']));require(_0xea26('0xc'))[_0xea26('0xd')](socket);function respondWithRpcPromise(_0x2225a7,_0x5b42eb,_0x53a18e){return new BPromise(function(_0x3d0190,_0x5b65b5){return client[_0xea26('0xe')](_0x2225a7,_0x53a18e)[_0xea26('0xf')](function(_0x374289){logger[_0xea26('0x10')]('SmsQueue,\x20%s,\x20%s',_0x5b42eb,_0xea26('0x11'));logger[_0xea26('0x12')]('SmsQueue,\x20%s,\x20%s,\x20%s',_0x5b42eb,_0xea26('0x11'),JSON[_0xea26('0x13')](_0x374289));if(_0x374289[_0xea26('0x14')]){if(_0x374289['error'][_0xea26('0x15')]===0x1f4){logger[_0xea26('0x14')](_0xea26('0x16'),_0x5b42eb,_0x374289[_0xea26('0x14')][_0xea26('0x17')]);return _0x5b65b5(_0x374289[_0xea26('0x14')]['message']);}logger['error'](_0xea26('0x16'),_0x5b42eb,_0x374289[_0xea26('0x14')][_0xea26('0x17')]);return _0x3d0190(_0x374289['error']['message']);}else{logger[_0xea26('0x10')](_0xea26('0x16'),_0x5b42eb,_0xea26('0x11'));_0x3d0190(_0x374289['result'][_0xea26('0x17')]);}})[_0xea26('0x18')](function(_0x2e2ebd){logger['error'](_0xea26('0x16'),_0x5b42eb,_0x2e2ebd);_0x5b65b5(_0x2e2ebd);});});}exports[_0xea26('0x19')]=function(_0x4db950){var _0x4cce21=this;return new Promise(function(_0x1f76ac,_0x514754){return db[_0xea26('0x1a')][_0xea26('0x1b')]({'raw':_0x4db950[_0xea26('0x1c')]?_0x4db950['options'][_0xea26('0x1d')]===undefined?!![]:![]:!![],'where':_0x4db950[_0xea26('0x1c')]?_0x4db950[_0xea26('0x1c')]['where']||null:null,'attributes':_0x4db950[_0xea26('0x1c')]?_0x4db950[_0xea26('0x1c')][_0xea26('0x1e')]||null:null,'limit':_0x4db950[_0xea26('0x1c')]?_0x4db950[_0xea26('0x1c')][_0xea26('0x1f')]||null:null,'include':_0x4db950[_0xea26('0x1c')]?_0x4db950['options'][_0xea26('0x20')]?_[_0xea26('0x21')](_0x4db950[_0xea26('0x1c')][_0xea26('0x20')],function(_0x1d6ebf){return{'model':db[_0x1d6ebf[_0xea26('0x22')]],'as':_0x1d6ebf['as'],'attributes':_0x1d6ebf[_0xea26('0x1e')],'include':_0x1d6ebf[_0xea26('0x20')]?_['map'](_0x1d6ebf[_0xea26('0x20')],function(_0x2f2abd){return{'model':db[_0x2f2abd[_0xea26('0x22')]],'as':_0x2f2abd['as'],'attributes':_0x2f2abd[_0xea26('0x1e')],'include':_0x2f2abd[_0xea26('0x20')]?_[_0xea26('0x21')](_0x2f2abd[_0xea26('0x20')],function(_0x1af218){return{'model':db[_0x1af218['model']],'as':_0x1af218['as'],'attributes':_0x1af218[_0xea26('0x1e')]};}):[]};}):[]};}):[]:[]})[_0xea26('0xf')](function(_0x3d2ca8){logger['info'](_0xea26('0x19'),_0x4db950);logger[_0xea26('0x12')](_0xea26('0x19'),_0x4db950,JSON['stringify'](_0x3d2ca8));_0x1f76ac(_0x3d2ca8);})[_0xea26('0x18')](function(_0x1a5c18){logger[_0xea26('0x14')](_0xea26('0x19'),_0x1a5c18[_0xea26('0x17')],_0x4db950);_0x514754(_0x4cce21[_0xea26('0x14')](0x1f4,_0x1a5c18[_0xea26('0x17')]));});});};exports[_0xea26('0x23')]=function(_0x480104){var _0x5ad9b5=this;return new Promise(function(_0xdc63a9,_0x37e35e){return db[_0xea26('0x1a')][_0xea26('0x24')]({'raw':_0x480104['options']?_0x480104['options']['raw']===undefined?!![]:![]:!![],'where':_0x480104[_0xea26('0x1c')]?_0x480104['options']['where']||null:null,'attributes':_0x480104[_0xea26('0x1c')]?_0x480104[_0xea26('0x1c')][_0xea26('0x1e')]||null:null,'include':_0x480104[_0xea26('0x1c')]?_0x480104[_0xea26('0x1c')]['include']?_[_0xea26('0x21')](_0x480104[_0xea26('0x1c')]['include'],function(_0x4bc1af){return{'model':db[_0x4bc1af['model']],'as':_0x4bc1af['as'],'attributes':_0x4bc1af[_0xea26('0x1e')],'include':_0x4bc1af[_0xea26('0x20')]?_['map'](_0x4bc1af[_0xea26('0x20')],function(_0x28efd8){return{'model':db[_0x28efd8[_0xea26('0x22')]],'as':_0x28efd8['as'],'attributes':_0x28efd8['attributes'],'include':_0x28efd8[_0xea26('0x20')]?_['map'](_0x28efd8['include'],function(_0x30abaf){return{'model':db[_0x30abaf[_0xea26('0x22')]],'as':_0x30abaf['as'],'attributes':_0x30abaf[_0xea26('0x1e')]};}):[]};}):[]};}):[]:[]})[_0xea26('0xf')](function(_0x5f3dba){logger[_0xea26('0x10')](_0xea26('0x23'),_0x480104);logger[_0xea26('0x12')]('ShowSmsQueue',_0x480104,JSON[_0xea26('0x13')](_0x5f3dba));_0xdc63a9(_0x5f3dba);})[_0xea26('0x18')](function(_0x3e8382){logger[_0xea26('0x14')](_0xea26('0x23'),_0x3e8382[_0xea26('0x17')],_0x480104);_0x37e35e(_0x5ad9b5[_0xea26('0x14')](0x1f4,_0x3e8382[_0xea26('0x17')]));});});};