Built motion from commit (unavailable).|2.5.15
[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 _0x9f5b=['include','map','model','ShowSmsAccount','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','client','http','redis','./smsAccount.socket','register','request','then','request\x20sent','stringify','code','SmsAccount,\x20%s,\x20%s','error','message','info','result','catch','SmsAccount','options','raw','where','attributes'];(function(_0x34bf97,_0xc60f9d){var _0x292719=function(_0x31354e){while(--_0x31354e){_0x34bf97['push'](_0x34bf97['shift']());}};_0x292719(++_0xc60f9d);}(_0x9f5b,0xf9));var _0xb9f5=function(_0x40e3e6,_0x141bc1){_0x40e3e6=_0x40e3e6-0x0;var _0x601283=_0x9f5b[_0x40e3e6];return _0x601283;};'use strict';var _=require(_0xb9f5('0x0'));var util=require(_0xb9f5('0x1'));var moment=require(_0xb9f5('0x2'));var BPromise=require(_0xb9f5('0x3'));var rs=require(_0xb9f5('0x4'));var fs=require('fs');var Redis=require(_0xb9f5('0x5'));var db=require(_0xb9f5('0x6'))['db'];var utils=require(_0xb9f5('0x7'));var logger=require('../../config/logger')(_0xb9f5('0x8'));var config=require(_0xb9f5('0x9'));var jayson=require('jayson/promise');var client=jayson[_0xb9f5('0xa')][_0xb9f5('0xb')]({'port':0x232a});config[_0xb9f5('0xc')]=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xb9f5('0xc')]));require(_0xb9f5('0xd'))[_0xb9f5('0xe')](socket);function respondWithRpcPromise(_0x4c7b1e,_0x5af61c,_0x1b4d3a){return new BPromise(function(_0x4d86f5,_0x4d5b74){return client[_0xb9f5('0xf')](_0x4c7b1e,_0x1b4d3a)[_0xb9f5('0x10')](function(_0x22b2ff){logger['info']('SmsAccount,\x20%s,\x20%s',_0x5af61c,_0xb9f5('0x11'));logger['debug']('SmsAccount,\x20%s,\x20%s,\x20%s',_0x5af61c,'request\x20sent',JSON[_0xb9f5('0x12')](_0x22b2ff));if(_0x22b2ff['error']){if(_0x22b2ff['error'][_0xb9f5('0x13')]===0x1f4){logger['error'](_0xb9f5('0x14'),_0x5af61c,_0x22b2ff[_0xb9f5('0x15')]['message']);return _0x4d5b74(_0x22b2ff[_0xb9f5('0x15')]['message']);}logger[_0xb9f5('0x15')]('SmsAccount,\x20%s,\x20%s',_0x5af61c,_0x22b2ff[_0xb9f5('0x15')][_0xb9f5('0x16')]);return _0x4d86f5(_0x22b2ff[_0xb9f5('0x15')][_0xb9f5('0x16')]);}else{logger[_0xb9f5('0x17')](_0xb9f5('0x14'),_0x5af61c,_0xb9f5('0x11'));_0x4d86f5(_0x22b2ff[_0xb9f5('0x18')][_0xb9f5('0x16')]);}})[_0xb9f5('0x19')](function(_0x116051){logger['error'](_0xb9f5('0x14'),_0x5af61c,_0x116051);_0x4d5b74(_0x116051);});});}exports['ShowSmsAccount']=function(_0x4b1066){var _0x26e625=this;return new Promise(function(_0x419cfb,_0x4579e2){return db[_0xb9f5('0x1a')]['find']({'raw':_0x4b1066[_0xb9f5('0x1b')]?_0x4b1066[_0xb9f5('0x1b')][_0xb9f5('0x1c')]===undefined?!![]:![]:!![],'where':_0x4b1066['options']?_0x4b1066[_0xb9f5('0x1b')][_0xb9f5('0x1d')]||null:null,'attributes':_0x4b1066['options']?_0x4b1066[_0xb9f5('0x1b')][_0xb9f5('0x1e')]||null:null,'include':_0x4b1066[_0xb9f5('0x1b')]?_0x4b1066[_0xb9f5('0x1b')][_0xb9f5('0x1f')]?_[_0xb9f5('0x20')](_0x4b1066[_0xb9f5('0x1b')][_0xb9f5('0x1f')],function(_0x589e70){return{'model':db[_0x589e70[_0xb9f5('0x21')]],'as':_0x589e70['as'],'attributes':_0x589e70[_0xb9f5('0x1e')],'include':_0x589e70[_0xb9f5('0x1f')]?_[_0xb9f5('0x20')](_0x589e70[_0xb9f5('0x1f')],function(_0xa963de){return{'model':db[_0xa963de['model']],'as':_0xa963de['as'],'attributes':_0xa963de['attributes'],'include':_0xa963de['include']?_[_0xb9f5('0x20')](_0xa963de['include'],function(_0x4cb6bf){return{'model':db[_0x4cb6bf[_0xb9f5('0x21')]],'as':_0x4cb6bf['as'],'attributes':_0x4cb6bf[_0xb9f5('0x1e')]};}):[]};}):[]};}):[]:[]})[_0xb9f5('0x10')](function(_0x5540bd){logger[_0xb9f5('0x17')](_0xb9f5('0x22'),_0x4b1066);logger['debug'](_0xb9f5('0x22'),_0x4b1066,JSON[_0xb9f5('0x12')](_0x5540bd));_0x419cfb(_0x5540bd);})['catch'](function(_0x2e5091){logger['error'](_0xb9f5('0x22'),_0x2e5091['message'],_0x4b1066);_0x4579e2(_0x26e625[_0xb9f5('0x15')](0x1f4,_0x2e5091['message']));});});};