Built motion from commit (unavailable).|2.5.8
[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 _0x708a=['../../config/environment','client','redis','defaults','localhost','socket.io-emitter','./smsAccount.socket','register','request','info','SmsAccount,\x20%s,\x20%s','debug','SmsAccount,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','ShowSmsAccount','SmsAccount','find','options','raw','attributes','include','map','model','then','lodash','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc'];(function(_0x1f7899,_0x265e80){var _0x4fd6b5=function(_0xb250de){while(--_0xb250de){_0x1f7899['push'](_0x1f7899['shift']());}};_0x4fd6b5(++_0x265e80);}(_0x708a,0xb6));var _0xa708=function(_0x36793c,_0x3d105c){_0x36793c=_0x36793c-0x0;var _0x549162=_0x708a[_0x36793c];return _0x549162;};'use strict';var _=require(_0xa708('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0xa708('0x1'));var rs=require(_0xa708('0x2'));var fs=require('fs');var Redis=require(_0xa708('0x3'));var db=require(_0xa708('0x4'))['db'];var utils=require(_0xa708('0x5'));var logger=require(_0xa708('0x6'))(_0xa708('0x7'));var config=require(_0xa708('0x8'));var jayson=require('jayson/promise');var client=jayson[_0xa708('0x9')]['http']({'port':0x232a});config[_0xa708('0xa')]=_[_0xa708('0xb')](config[_0xa708('0xa')],{'host':_0xa708('0xc'),'port':0x18eb});var socket=require(_0xa708('0xd'))(new Redis(config[_0xa708('0xa')]));require(_0xa708('0xe'))[_0xa708('0xf')](socket);function respondWithRpcPromise(_0x1f4b0c,_0x3f4630,_0x57906d){return new BPromise(function(_0x1970e1,_0x23763e){return client[_0xa708('0x10')](_0x1f4b0c,_0x57906d)['then'](function(_0x4f7410){logger[_0xa708('0x11')](_0xa708('0x12'),_0x3f4630,'request\x20sent');logger[_0xa708('0x13')](_0xa708('0x14'),_0x3f4630,_0xa708('0x15'),JSON[_0xa708('0x16')](_0x4f7410));if(_0x4f7410['error']){if(_0x4f7410[_0xa708('0x17')][_0xa708('0x18')]===0x1f4){logger[_0xa708('0x17')](_0xa708('0x12'),_0x3f4630,_0x4f7410[_0xa708('0x17')]['message']);return _0x23763e(_0x4f7410[_0xa708('0x17')][_0xa708('0x19')]);}logger[_0xa708('0x17')](_0xa708('0x12'),_0x3f4630,_0x4f7410[_0xa708('0x17')][_0xa708('0x19')]);return _0x1970e1(_0x4f7410['error'][_0xa708('0x19')]);}else{logger['info']('SmsAccount,\x20%s,\x20%s',_0x3f4630,'request\x20sent');_0x1970e1(_0x4f7410[_0xa708('0x1a')]['message']);}})[_0xa708('0x1b')](function(_0x5c0d59){logger[_0xa708('0x17')](_0xa708('0x12'),_0x3f4630,_0x5c0d59);_0x23763e(_0x5c0d59);});});}exports[_0xa708('0x1c')]=function(_0x205937){var _0x23ee08=this;return new Promise(function(_0x5f1241,_0x188a0e){return db[_0xa708('0x1d')][_0xa708('0x1e')]({'raw':_0x205937[_0xa708('0x1f')]?_0x205937[_0xa708('0x1f')][_0xa708('0x20')]===undefined?!![]:![]:!![],'where':_0x205937['options']?_0x205937['options']['where']||null:null,'attributes':_0x205937[_0xa708('0x1f')]?_0x205937[_0xa708('0x1f')][_0xa708('0x21')]||null:null,'include':_0x205937['options']?_0x205937[_0xa708('0x1f')][_0xa708('0x22')]?_['map'](_0x205937[_0xa708('0x1f')]['include'],function(_0x14612d){return{'model':db[_0x14612d['model']],'as':_0x14612d['as'],'attributes':_0x14612d[_0xa708('0x21')],'include':_0x14612d[_0xa708('0x22')]?_[_0xa708('0x23')](_0x14612d[_0xa708('0x22')],function(_0x10038b){return{'model':db[_0x10038b['model']],'as':_0x10038b['as'],'attributes':_0x10038b[_0xa708('0x21')],'include':_0x10038b['include']?_[_0xa708('0x23')](_0x10038b[_0xa708('0x22')],function(_0x3a174b){return{'model':db[_0x3a174b[_0xa708('0x24')]],'as':_0x3a174b['as'],'attributes':_0x3a174b['attributes']};}):[]};}):[]};}):[]:[]})[_0xa708('0x25')](function(_0x3c4a41){logger[_0xa708('0x11')]('ShowSmsAccount',_0x205937);logger['debug'](_0xa708('0x1c'),_0x205937,JSON[_0xa708('0x16')](_0x3c4a41));_0x5f1241(_0x3c4a41);})[_0xa708('0x1b')](function(_0x4ba2b5){logger[_0xa708('0x17')](_0xa708('0x1c'),_0x4ba2b5[_0xa708('0x19')],_0x205937);_0x188a0e(_0x23ee08[_0xa708('0x17')](0x1f4,_0x4ba2b5[_0xa708('0x19')]));});});};