Built motion from commit (unavailable).|2.5.22
[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 _0x30a1=['moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./smsAccount.socket','request','then','info','SmsAccount,\x20%s,\x20%s','debug','SmsAccount,\x20%s,\x20%s,\x20%s','stringify','code','error','message','request\x20sent','result','ShowSmsAccount','SmsAccount','find','raw','options','where','attributes','map','include','model','catch','lodash','util'];(function(_0x3d4e74,_0x21b4e5){var _0x57613d=function(_0x2fa3b3){while(--_0x2fa3b3){_0x3d4e74['push'](_0x3d4e74['shift']());}};_0x57613d(++_0x21b4e5);}(_0x30a1,0x1de));var _0x130a=function(_0x14add3,_0x13ce8d){_0x14add3=_0x14add3-0x0;var _0x4a174f=_0x30a1[_0x14add3];return _0x4a174f;};'use strict';var _=require(_0x130a('0x0'));var util=require(_0x130a('0x1'));var moment=require(_0x130a('0x2'));var BPromise=require(_0x130a('0x3'));var rs=require(_0x130a('0x4'));var fs=require('fs');var Redis=require(_0x130a('0x5'));var db=require(_0x130a('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0x130a('0x7'))('rpc');var config=require(_0x130a('0x8'));var jayson=require(_0x130a('0x9'));var client=jayson[_0x130a('0xa')][_0x130a('0xb')]({'port':0x232a});config[_0x130a('0xc')]=_[_0x130a('0xd')](config[_0x130a('0xc')],{'host':_0x130a('0xe'),'port':0x18eb});var socket=require(_0x130a('0xf'))(new Redis(config[_0x130a('0xc')]));require(_0x130a('0x10'))['register'](socket);function respondWithRpcPromise(_0x3e4c83,_0x571f4b,_0x45a769){return new BPromise(function(_0x4db058,_0x34cd6e){return client[_0x130a('0x11')](_0x3e4c83,_0x45a769)[_0x130a('0x12')](function(_0x4d030d){logger[_0x130a('0x13')](_0x130a('0x14'),_0x571f4b,'request\x20sent');logger[_0x130a('0x15')](_0x130a('0x16'),_0x571f4b,'request\x20sent',JSON[_0x130a('0x17')](_0x4d030d));if(_0x4d030d['error']){if(_0x4d030d['error'][_0x130a('0x18')]===0x1f4){logger[_0x130a('0x19')](_0x130a('0x14'),_0x571f4b,_0x4d030d[_0x130a('0x19')][_0x130a('0x1a')]);return _0x34cd6e(_0x4d030d[_0x130a('0x19')][_0x130a('0x1a')]);}logger[_0x130a('0x19')](_0x130a('0x14'),_0x571f4b,_0x4d030d['error'][_0x130a('0x1a')]);return _0x4db058(_0x4d030d[_0x130a('0x19')][_0x130a('0x1a')]);}else{logger[_0x130a('0x13')]('SmsAccount,\x20%s,\x20%s',_0x571f4b,_0x130a('0x1b'));_0x4db058(_0x4d030d[_0x130a('0x1c')][_0x130a('0x1a')]);}})['catch'](function(_0x294b77){logger[_0x130a('0x19')](_0x130a('0x14'),_0x571f4b,_0x294b77);_0x34cd6e(_0x294b77);});});}exports[_0x130a('0x1d')]=function(_0x3f9636){var _0x37ae78=this;return new Promise(function(_0x4e49a3,_0x3a1e0f){return db[_0x130a('0x1e')][_0x130a('0x1f')]({'raw':_0x3f9636['options']?_0x3f9636['options'][_0x130a('0x20')]===undefined?!![]:![]:!![],'where':_0x3f9636[_0x130a('0x21')]?_0x3f9636[_0x130a('0x21')][_0x130a('0x22')]||null:null,'attributes':_0x3f9636[_0x130a('0x21')]?_0x3f9636[_0x130a('0x21')][_0x130a('0x23')]||null:null,'include':_0x3f9636[_0x130a('0x21')]?_0x3f9636['options']['include']?_[_0x130a('0x24')](_0x3f9636['options'][_0x130a('0x25')],function(_0x3c0383){return{'model':db[_0x3c0383[_0x130a('0x26')]],'as':_0x3c0383['as'],'attributes':_0x3c0383['attributes'],'include':_0x3c0383[_0x130a('0x25')]?_[_0x130a('0x24')](_0x3c0383[_0x130a('0x25')],function(_0x2eb353){return{'model':db[_0x2eb353[_0x130a('0x26')]],'as':_0x2eb353['as'],'attributes':_0x2eb353[_0x130a('0x23')],'include':_0x2eb353[_0x130a('0x25')]?_[_0x130a('0x24')](_0x2eb353['include'],function(_0x32e7bd){return{'model':db[_0x32e7bd[_0x130a('0x26')]],'as':_0x32e7bd['as'],'attributes':_0x32e7bd['attributes']};}):[]};}):[]};}):[]:[]})[_0x130a('0x12')](function(_0x112970){logger[_0x130a('0x13')]('ShowSmsAccount',_0x3f9636);logger['debug']('ShowSmsAccount',_0x3f9636,JSON[_0x130a('0x17')](_0x112970));_0x4e49a3(_0x112970);})[_0x130a('0x27')](function(_0x2daadd){logger['error'](_0x130a('0x1d'),_0x2daadd[_0x130a('0x1a')],_0x3f9636);_0x3a1e0f(_0x37ae78['error'](0x1f4,_0x2daadd[_0x130a('0x1a')]));});});};