Built motion from commit 25580385.|2.6.2
[motion2.git] / server / api / smsAccount / smsAccount.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 _0xc3cc=['error','code','message','info','result','catch','ShowSmsAccount','SmsAccount','find','options','raw','where','attributes','include','map','model','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','jayson/promise','client','http','defaults','redis','./smsAccount.socket','request','then','SmsAccount,\x20%s,\x20%s','request\x20sent','debug','SmsAccount,\x20%s,\x20%s,\x20%s','stringify'];(function(_0x4c5ffd,_0x5c077f){var _0x5fe9d6=function(_0x1ba741){while(--_0x1ba741){_0x4c5ffd['push'](_0x4c5ffd['shift']());}};_0x5fe9d6(++_0x5c077f);}(_0xc3cc,0xe8));var _0xcc3c=function(_0x435150,_0x591cd9){_0x435150=_0x435150-0x0;var _0x13b3a4=_0xc3cc[_0x435150];return _0x13b3a4;};'use strict';var _=require(_0xcc3c('0x0'));var util=require(_0xcc3c('0x1'));var moment=require(_0xcc3c('0x2'));var BPromise=require(_0xcc3c('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xcc3c('0x4'));var db=require(_0xcc3c('0x5'))['db'];var utils=require(_0xcc3c('0x6'));var logger=require('../../config/logger')('rpc');var config=require('../../config/environment');var jayson=require(_0xcc3c('0x7'));var client=jayson[_0xcc3c('0x8')][_0xcc3c('0x9')]({'port':0x232a});config['redis']=_[_0xcc3c('0xa')](config[_0xcc3c('0xb')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xcc3c('0xb')]));require(_0xcc3c('0xc'))['register'](socket);function respondWithRpcPromise(_0x3c806f,_0x9dd067,_0x50bcc3){return new BPromise(function(_0x420ff3,_0x426167){return client[_0xcc3c('0xd')](_0x3c806f,_0x50bcc3)[_0xcc3c('0xe')](function(_0x1777c2){logger['info'](_0xcc3c('0xf'),_0x9dd067,_0xcc3c('0x10'));logger[_0xcc3c('0x11')](_0xcc3c('0x12'),_0x9dd067,'request\x20sent',JSON[_0xcc3c('0x13')](_0x1777c2));if(_0x1777c2[_0xcc3c('0x14')]){if(_0x1777c2[_0xcc3c('0x14')][_0xcc3c('0x15')]===0x1f4){logger['error'](_0xcc3c('0xf'),_0x9dd067,_0x1777c2['error']['message']);return _0x426167(_0x1777c2[_0xcc3c('0x14')]['message']);}logger['error'](_0xcc3c('0xf'),_0x9dd067,_0x1777c2['error'][_0xcc3c('0x16')]);return _0x420ff3(_0x1777c2[_0xcc3c('0x14')][_0xcc3c('0x16')]);}else{logger[_0xcc3c('0x17')](_0xcc3c('0xf'),_0x9dd067,'request\x20sent');_0x420ff3(_0x1777c2[_0xcc3c('0x18')][_0xcc3c('0x16')]);}})[_0xcc3c('0x19')](function(_0x4ddb6c){logger['error']('SmsAccount,\x20%s,\x20%s',_0x9dd067,_0x4ddb6c);_0x426167(_0x4ddb6c);});});}exports[_0xcc3c('0x1a')]=function(_0x2b97ba){var _0x383318=this;return new Promise(function(_0x532603,_0x1eca54){return db[_0xcc3c('0x1b')][_0xcc3c('0x1c')]({'raw':_0x2b97ba[_0xcc3c('0x1d')]?_0x2b97ba['options'][_0xcc3c('0x1e')]===undefined?!![]:![]:!![],'where':_0x2b97ba[_0xcc3c('0x1d')]?_0x2b97ba[_0xcc3c('0x1d')][_0xcc3c('0x1f')]||null:null,'attributes':_0x2b97ba['options']?_0x2b97ba[_0xcc3c('0x1d')][_0xcc3c('0x20')]||null:null,'include':_0x2b97ba['options']?_0x2b97ba[_0xcc3c('0x1d')][_0xcc3c('0x21')]?_[_0xcc3c('0x22')](_0x2b97ba['options'][_0xcc3c('0x21')],function(_0x37696d){return{'model':db[_0x37696d[_0xcc3c('0x23')]],'as':_0x37696d['as'],'attributes':_0x37696d[_0xcc3c('0x20')],'include':_0x37696d['include']?_['map'](_0x37696d[_0xcc3c('0x21')],function(_0x582c61){return{'model':db[_0x582c61[_0xcc3c('0x23')]],'as':_0x582c61['as'],'attributes':_0x582c61['attributes'],'include':_0x582c61[_0xcc3c('0x21')]?_['map'](_0x582c61[_0xcc3c('0x21')],function(_0x533ba6){return{'model':db[_0x533ba6[_0xcc3c('0x23')]],'as':_0x533ba6['as'],'attributes':_0x533ba6[_0xcc3c('0x20')]};}):[]};}):[]};}):[]:[]})[_0xcc3c('0xe')](function(_0x4446f0){logger[_0xcc3c('0x17')](_0xcc3c('0x1a'),_0x2b97ba);logger[_0xcc3c('0x11')](_0xcc3c('0x1a'),_0x2b97ba,JSON[_0xcc3c('0x13')](_0x4446f0));_0x532603(_0x4446f0);})[_0xcc3c('0x19')](function(_0x27e436){logger[_0xcc3c('0x14')](_0xcc3c('0x1a'),_0x27e436[_0xcc3c('0x16')],_0x2b97ba);_0x1eca54(_0x383318['error'](0x1f4,_0x27e436[_0xcc3c('0x16')]));});});};