Built motion from commit dbf3a7e2.|2.6.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 _0xbc61=['map','catch','ShowSmsQueue','lodash','util','moment','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','client','defaults','redis','localhost','socket.io-emitter','./smsQueue.socket','request','then','info','SmsQueue,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','GetSmsQueue','SmsQueue','options','raw','where','attributes','limit','include','model'];(function(_0x3fdf8f,_0x437193){var _0x3852a7=function(_0x4012e6){while(--_0x4012e6){_0x3fdf8f['push'](_0x3fdf8f['shift']());}};_0x3852a7(++_0x437193);}(_0xbc61,0x123));var _0x1bc6=function(_0x2ac2f4,_0x1c790c){_0x2ac2f4=_0x2ac2f4-0x0;var _0x24bbd8=_0xbc61[_0x2ac2f4];return _0x24bbd8;};'use strict';var _=require(_0x1bc6('0x0'));var util=require(_0x1bc6('0x1'));var moment=require(_0x1bc6('0x2'));var BPromise=require('bluebird');var rs=require(_0x1bc6('0x3'));var fs=require('fs');var Redis=require(_0x1bc6('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x1bc6('0x5'));var logger=require(_0x1bc6('0x6'))(_0x1bc6('0x7'));var config=require(_0x1bc6('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x1bc6('0x9')]['http']({'port':0x232a});config['redis']=_[_0x1bc6('0xa')](config[_0x1bc6('0xb')],{'host':_0x1bc6('0xc'),'port':0x18eb});var socket=require(_0x1bc6('0xd'))(new Redis(config['redis']));require(_0x1bc6('0xe'))['register'](socket);function respondWithRpcPromise(_0x4e30d9,_0xb5035f,_0x4d6726){return new BPromise(function(_0x36eef6,_0x32bcd2){return client[_0x1bc6('0xf')](_0x4e30d9,_0x4d6726)[_0x1bc6('0x10')](function(_0x4feb2d){logger[_0x1bc6('0x11')](_0x1bc6('0x12'),_0xb5035f,_0x1bc6('0x13'));logger[_0x1bc6('0x14')]('SmsQueue,\x20%s,\x20%s,\x20%s',_0xb5035f,'request\x20sent',JSON[_0x1bc6('0x15')](_0x4feb2d));if(_0x4feb2d[_0x1bc6('0x16')]){if(_0x4feb2d[_0x1bc6('0x16')]['code']===0x1f4){logger[_0x1bc6('0x16')](_0x1bc6('0x12'),_0xb5035f,_0x4feb2d[_0x1bc6('0x16')][_0x1bc6('0x17')]);return _0x32bcd2(_0x4feb2d[_0x1bc6('0x16')][_0x1bc6('0x17')]);}logger[_0x1bc6('0x16')](_0x1bc6('0x12'),_0xb5035f,_0x4feb2d[_0x1bc6('0x16')][_0x1bc6('0x17')]);return _0x36eef6(_0x4feb2d[_0x1bc6('0x16')][_0x1bc6('0x17')]);}else{logger[_0x1bc6('0x11')]('SmsQueue,\x20%s,\x20%s',_0xb5035f,_0x1bc6('0x13'));_0x36eef6(_0x4feb2d['result'][_0x1bc6('0x17')]);}})['catch'](function(_0x178c3c){logger[_0x1bc6('0x16')](_0x1bc6('0x12'),_0xb5035f,_0x178c3c);_0x32bcd2(_0x178c3c);});});}exports[_0x1bc6('0x18')]=function(_0x25da36){var _0x1514a3=this;return new Promise(function(_0x306645,_0x403c42){return db[_0x1bc6('0x19')]['findAll']({'raw':_0x25da36[_0x1bc6('0x1a')]?_0x25da36[_0x1bc6('0x1a')][_0x1bc6('0x1b')]===undefined?!![]:![]:!![],'where':_0x25da36['options']?_0x25da36['options'][_0x1bc6('0x1c')]||null:null,'attributes':_0x25da36[_0x1bc6('0x1a')]?_0x25da36[_0x1bc6('0x1a')][_0x1bc6('0x1d')]||null:null,'limit':_0x25da36[_0x1bc6('0x1a')]?_0x25da36[_0x1bc6('0x1a')][_0x1bc6('0x1e')]||null:null,'include':_0x25da36['options']?_0x25da36[_0x1bc6('0x1a')][_0x1bc6('0x1f')]?_['map'](_0x25da36[_0x1bc6('0x1a')][_0x1bc6('0x1f')],function(_0x4ce442){return{'model':db[_0x4ce442[_0x1bc6('0x20')]],'as':_0x4ce442['as'],'attributes':_0x4ce442[_0x1bc6('0x1d')],'include':_0x4ce442[_0x1bc6('0x1f')]?_[_0x1bc6('0x21')](_0x4ce442[_0x1bc6('0x1f')],function(_0x563c85){return{'model':db[_0x563c85[_0x1bc6('0x20')]],'as':_0x563c85['as'],'attributes':_0x563c85[_0x1bc6('0x1d')],'include':_0x563c85[_0x1bc6('0x1f')]?_[_0x1bc6('0x21')](_0x563c85[_0x1bc6('0x1f')],function(_0x2ff157){return{'model':db[_0x2ff157['model']],'as':_0x2ff157['as'],'attributes':_0x2ff157['attributes']};}):[]};}):[]};}):[]:[]})[_0x1bc6('0x10')](function(_0x534f0a){logger[_0x1bc6('0x11')](_0x1bc6('0x18'),_0x25da36);logger['debug'](_0x1bc6('0x18'),_0x25da36,JSON[_0x1bc6('0x15')](_0x534f0a));_0x306645(_0x534f0a);})[_0x1bc6('0x22')](function(_0x50c699){logger[_0x1bc6('0x16')]('GetSmsQueue',_0x50c699['message'],_0x25da36);_0x403c42(_0x1514a3[_0x1bc6('0x16')](0x1f4,_0x50c699[_0x1bc6('0x17')]));});});};exports[_0x1bc6('0x23')]=function(_0x2c8bae){var _0x159786=this;return new Promise(function(_0x167203,_0x2e463d){return db[_0x1bc6('0x19')]['find']({'raw':_0x2c8bae[_0x1bc6('0x1a')]?_0x2c8bae['options']['raw']===undefined?!![]:![]:!![],'where':_0x2c8bae[_0x1bc6('0x1a')]?_0x2c8bae['options'][_0x1bc6('0x1c')]||null:null,'attributes':_0x2c8bae[_0x1bc6('0x1a')]?_0x2c8bae[_0x1bc6('0x1a')][_0x1bc6('0x1d')]||null:null,'include':_0x2c8bae[_0x1bc6('0x1a')]?_0x2c8bae[_0x1bc6('0x1a')][_0x1bc6('0x1f')]?_['map'](_0x2c8bae['options'][_0x1bc6('0x1f')],function(_0x50a2d8){return{'model':db[_0x50a2d8['model']],'as':_0x50a2d8['as'],'attributes':_0x50a2d8['attributes'],'include':_0x50a2d8['include']?_['map'](_0x50a2d8[_0x1bc6('0x1f')],function(_0x4b6f5e){return{'model':db[_0x4b6f5e[_0x1bc6('0x20')]],'as':_0x4b6f5e['as'],'attributes':_0x4b6f5e[_0x1bc6('0x1d')],'include':_0x4b6f5e[_0x1bc6('0x1f')]?_[_0x1bc6('0x21')](_0x4b6f5e['include'],function(_0x4d13e9){return{'model':db[_0x4d13e9['model']],'as':_0x4d13e9['as'],'attributes':_0x4d13e9[_0x1bc6('0x1d')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x18ac8b){logger['info'](_0x1bc6('0x23'),_0x2c8bae);logger[_0x1bc6('0x14')]('ShowSmsQueue',_0x2c8bae,JSON[_0x1bc6('0x15')](_0x18ac8b));_0x167203(_0x18ac8b);})['catch'](function(_0x5e7107){logger['error'](_0x1bc6('0x23'),_0x5e7107[_0x1bc6('0x17')],_0x2c8bae);_0x2e463d(_0x159786['error'](0x1f4,_0x5e7107['message']));});});};