Built motion from commit (unavailable).|2.5.4
[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 _0x7529=['debug','stringify','util','moment','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','redis','defaults','localhost','socket.io-emitter','./smsAccount.socket','register','request','then','info','SmsAccount,\x20%s,\x20%s','request\x20sent','SmsAccount,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','ShowSmsAccount','SmsAccount','options','raw','attributes','include','model','map'];(function(_0x4bc65f,_0x39ec43){var _0x44f85f=function(_0x175343){while(--_0x175343){_0x4bc65f['push'](_0x4bc65f['shift']());}};_0x44f85f(++_0x39ec43);}(_0x7529,0x16a));var _0x9752=function(_0x1b9f08,_0x375081){_0x1b9f08=_0x1b9f08-0x0;var _0x3f9478=_0x7529[_0x1b9f08];return _0x3f9478;};'use strict';var _=require('lodash');var util=require(_0x9752('0x0'));var moment=require(_0x9752('0x1'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x9752('0x2'));var db=require(_0x9752('0x3'))['db'];var utils=require(_0x9752('0x4'));var logger=require(_0x9752('0x5'))(_0x9752('0x6'));var config=require(_0x9752('0x7'));var jayson=require(_0x9752('0x8'));var client=jayson['client']['http']({'port':0x232a});config[_0x9752('0x9')]=_[_0x9752('0xa')](config[_0x9752('0x9')],{'host':_0x9752('0xb'),'port':0x18eb});var socket=require(_0x9752('0xc'))(new Redis(config['redis']));require(_0x9752('0xd'))[_0x9752('0xe')](socket);function respondWithRpcPromise(_0x429a22,_0x20f315,_0x3777db){return new BPromise(function(_0x14bae3,_0x4040e3){return client[_0x9752('0xf')](_0x429a22,_0x3777db)[_0x9752('0x10')](function(_0x5e2da6){logger[_0x9752('0x11')](_0x9752('0x12'),_0x20f315,_0x9752('0x13'));logger['debug'](_0x9752('0x14'),_0x20f315,_0x9752('0x13'),JSON['stringify'](_0x5e2da6));if(_0x5e2da6[_0x9752('0x15')]){if(_0x5e2da6['error'][_0x9752('0x16')]===0x1f4){logger[_0x9752('0x15')]('SmsAccount,\x20%s,\x20%s',_0x20f315,_0x5e2da6[_0x9752('0x15')][_0x9752('0x17')]);return _0x4040e3(_0x5e2da6[_0x9752('0x15')][_0x9752('0x17')]);}logger[_0x9752('0x15')](_0x9752('0x12'),_0x20f315,_0x5e2da6[_0x9752('0x15')]['message']);return _0x14bae3(_0x5e2da6['error'][_0x9752('0x17')]);}else{logger[_0x9752('0x11')](_0x9752('0x12'),_0x20f315,_0x9752('0x13'));_0x14bae3(_0x5e2da6[_0x9752('0x18')][_0x9752('0x17')]);}})[_0x9752('0x19')](function(_0x1fcb32){logger[_0x9752('0x15')](_0x9752('0x12'),_0x20f315,_0x1fcb32);_0x4040e3(_0x1fcb32);});});}exports[_0x9752('0x1a')]=function(_0x35112b){var _0x54abc3=this;return new Promise(function(_0x2438b0,_0x4af019){return db[_0x9752('0x1b')]['find']({'raw':_0x35112b[_0x9752('0x1c')]?_0x35112b[_0x9752('0x1c')][_0x9752('0x1d')]===undefined?!![]:![]:!![],'where':_0x35112b[_0x9752('0x1c')]?_0x35112b[_0x9752('0x1c')]['where']||null:null,'attributes':_0x35112b[_0x9752('0x1c')]?_0x35112b[_0x9752('0x1c')][_0x9752('0x1e')]||null:null,'include':_0x35112b[_0x9752('0x1c')]?_0x35112b[_0x9752('0x1c')]['include']?_['map'](_0x35112b[_0x9752('0x1c')][_0x9752('0x1f')],function(_0x5a948d){return{'model':db[_0x5a948d[_0x9752('0x20')]],'as':_0x5a948d['as'],'attributes':_0x5a948d[_0x9752('0x1e')],'include':_0x5a948d[_0x9752('0x1f')]?_[_0x9752('0x21')](_0x5a948d[_0x9752('0x1f')],function(_0x121ead){return{'model':db[_0x121ead[_0x9752('0x20')]],'as':_0x121ead['as'],'attributes':_0x121ead[_0x9752('0x1e')],'include':_0x121ead[_0x9752('0x1f')]?_[_0x9752('0x21')](_0x121ead[_0x9752('0x1f')],function(_0x56838a){return{'model':db[_0x56838a[_0x9752('0x20')]],'as':_0x56838a['as'],'attributes':_0x56838a[_0x9752('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x9752('0x10')](function(_0x2c57a2){logger[_0x9752('0x11')](_0x9752('0x1a'),_0x35112b);logger[_0x9752('0x22')](_0x9752('0x1a'),_0x35112b,JSON[_0x9752('0x23')](_0x2c57a2));_0x2438b0(_0x2c57a2);})[_0x9752('0x19')](function(_0x4ecdf0){logger['error'](_0x9752('0x1a'),_0x4ecdf0[_0x9752('0x17')],_0x35112b);_0x4af019(_0x54abc3[_0x9752('0x15')](0x1f4,_0x4ecdf0[_0x9752('0x17')]));});});};