Built motion from commit ddca4d0d.|2.5.47
[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 _0xecf4=['defaults','redis','localhost','socket.io-emitter','./smsAccount.socket','register','request','then','info','SmsAccount,\x20%s,\x20%s','debug','SmsAccount,\x20%s,\x20%s,\x20%s','request\x20sent','error','message','result','catch','ShowSmsAccount','SmsAccount','find','options','include','map','model','attributes','stringify','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','../../config/environment','client','http'];(function(_0x514efd,_0x4f5f10){var _0x2d5148=function(_0xa12e51){while(--_0xa12e51){_0x514efd['push'](_0x514efd['shift']());}};_0x2d5148(++_0x4f5f10);}(_0xecf4,0x11d));var _0x4ecf=function(_0x3c51d4,_0x36ba53){_0x3c51d4=_0x3c51d4-0x0;var _0x53c45f=_0xecf4[_0x3c51d4];return _0x53c45f;};'use strict';var _=require(_0x4ecf('0x0'));var util=require(_0x4ecf('0x1'));var moment=require(_0x4ecf('0x2'));var BPromise=require(_0x4ecf('0x3'));var rs=require(_0x4ecf('0x4'));var fs=require('fs');var Redis=require(_0x4ecf('0x5'));var db=require(_0x4ecf('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0x4ecf('0x7'))('rpc');var config=require(_0x4ecf('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x4ecf('0x9')][_0x4ecf('0xa')]({'port':0x232a});config['redis']=_[_0x4ecf('0xb')](config[_0x4ecf('0xc')],{'host':_0x4ecf('0xd'),'port':0x18eb});var socket=require(_0x4ecf('0xe'))(new Redis(config[_0x4ecf('0xc')]));require(_0x4ecf('0xf'))[_0x4ecf('0x10')](socket);function respondWithRpcPromise(_0xcc89e2,_0x8311d9,_0x32e8bd){return new BPromise(function(_0x26d537,_0x1c3761){return client[_0x4ecf('0x11')](_0xcc89e2,_0x32e8bd)[_0x4ecf('0x12')](function(_0x29122e){logger[_0x4ecf('0x13')](_0x4ecf('0x14'),_0x8311d9,'request\x20sent');logger[_0x4ecf('0x15')](_0x4ecf('0x16'),_0x8311d9,_0x4ecf('0x17'),JSON['stringify'](_0x29122e));if(_0x29122e['error']){if(_0x29122e[_0x4ecf('0x18')]['code']===0x1f4){logger[_0x4ecf('0x18')](_0x4ecf('0x14'),_0x8311d9,_0x29122e[_0x4ecf('0x18')]['message']);return _0x1c3761(_0x29122e[_0x4ecf('0x18')][_0x4ecf('0x19')]);}logger[_0x4ecf('0x18')](_0x4ecf('0x14'),_0x8311d9,_0x29122e[_0x4ecf('0x18')][_0x4ecf('0x19')]);return _0x26d537(_0x29122e[_0x4ecf('0x18')][_0x4ecf('0x19')]);}else{logger[_0x4ecf('0x13')](_0x4ecf('0x14'),_0x8311d9,'request\x20sent');_0x26d537(_0x29122e[_0x4ecf('0x1a')][_0x4ecf('0x19')]);}})[_0x4ecf('0x1b')](function(_0x6da7fa){logger['error']('SmsAccount,\x20%s,\x20%s',_0x8311d9,_0x6da7fa);_0x1c3761(_0x6da7fa);});});}exports[_0x4ecf('0x1c')]=function(_0x3ae962){var _0x207f20=this;return new Promise(function(_0x87f13d,_0x362224){return db[_0x4ecf('0x1d')][_0x4ecf('0x1e')]({'raw':_0x3ae962[_0x4ecf('0x1f')]?_0x3ae962['options']['raw']===undefined?!![]:![]:!![],'where':_0x3ae962[_0x4ecf('0x1f')]?_0x3ae962[_0x4ecf('0x1f')]['where']||null:null,'attributes':_0x3ae962[_0x4ecf('0x1f')]?_0x3ae962['options']['attributes']||null:null,'include':_0x3ae962[_0x4ecf('0x1f')]?_0x3ae962[_0x4ecf('0x1f')][_0x4ecf('0x20')]?_[_0x4ecf('0x21')](_0x3ae962[_0x4ecf('0x1f')][_0x4ecf('0x20')],function(_0x1aeeae){return{'model':db[_0x1aeeae[_0x4ecf('0x22')]],'as':_0x1aeeae['as'],'attributes':_0x1aeeae[_0x4ecf('0x23')],'include':_0x1aeeae[_0x4ecf('0x20')]?_[_0x4ecf('0x21')](_0x1aeeae['include'],function(_0x2c5ead){return{'model':db[_0x2c5ead['model']],'as':_0x2c5ead['as'],'attributes':_0x2c5ead[_0x4ecf('0x23')],'include':_0x2c5ead[_0x4ecf('0x20')]?_['map'](_0x2c5ead['include'],function(_0x46a0a2){return{'model':db[_0x46a0a2[_0x4ecf('0x22')]],'as':_0x46a0a2['as'],'attributes':_0x46a0a2[_0x4ecf('0x23')]};}):[]};}):[]};}):[]:[]})[_0x4ecf('0x12')](function(_0x1ca209){logger[_0x4ecf('0x13')](_0x4ecf('0x1c'),_0x3ae962);logger[_0x4ecf('0x15')](_0x4ecf('0x1c'),_0x3ae962,JSON[_0x4ecf('0x24')](_0x1ca209));_0x87f13d(_0x1ca209);})[_0x4ecf('0x1b')](function(_0x1fe345){logger[_0x4ecf('0x18')]('ShowSmsAccount',_0x1fe345['message'],_0x3ae962);_0x362224(_0x207f20[_0x4ecf('0x18')](0x1f4,_0x1fe345[_0x4ecf('0x19')]));});});};