Built motion from commit (unavailable).|2.5.9
[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 _0xaae2=['options','where','include','map','model','attributes','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','redis','socket.io-emitter','./smsAccount.socket','register','request','then','info','SmsAccount,\x20%s,\x20%s','request\x20sent','debug','stringify','code','error','message','catch','ShowSmsAccount','SmsAccount','find','raw'];(function(_0x3db2ec,_0x27f18d){var _0x4ba8b0=function(_0x5516a6){while(--_0x5516a6){_0x3db2ec['push'](_0x3db2ec['shift']());}};_0x4ba8b0(++_0x27f18d);}(_0xaae2,0x1c2));var _0x2aae=function(_0x46588c,_0x4d7dcb){_0x46588c=_0x46588c-0x0;var _0x558526=_0xaae2[_0x46588c];return _0x558526;};'use strict';var _=require(_0x2aae('0x0'));var util=require(_0x2aae('0x1'));var moment=require('moment');var BPromise=require(_0x2aae('0x2'));var rs=require(_0x2aae('0x3'));var fs=require('fs');var Redis=require(_0x2aae('0x4'));var db=require(_0x2aae('0x5'))['db'];var utils=require(_0x2aae('0x6'));var logger=require(_0x2aae('0x7'))('rpc');var config=require(_0x2aae('0x8'));var jayson=require(_0x2aae('0x9'));var client=jayson[_0x2aae('0xa')][_0x2aae('0xb')]({'port':0x232a});config[_0x2aae('0xc')]=_['defaults'](config[_0x2aae('0xc')],{'host':'localhost','port':0x18eb});var socket=require(_0x2aae('0xd'))(new Redis(config[_0x2aae('0xc')]));require(_0x2aae('0xe'))[_0x2aae('0xf')](socket);function respondWithRpcPromise(_0x51f8d6,_0x6db707,_0x4d8dfd){return new BPromise(function(_0x63158f,_0x48db15){return client[_0x2aae('0x10')](_0x51f8d6,_0x4d8dfd)[_0x2aae('0x11')](function(_0x132d11){logger[_0x2aae('0x12')](_0x2aae('0x13'),_0x6db707,_0x2aae('0x14'));logger[_0x2aae('0x15')]('SmsAccount,\x20%s,\x20%s,\x20%s',_0x6db707,_0x2aae('0x14'),JSON[_0x2aae('0x16')](_0x132d11));if(_0x132d11['error']){if(_0x132d11['error'][_0x2aae('0x17')]===0x1f4){logger[_0x2aae('0x18')](_0x2aae('0x13'),_0x6db707,_0x132d11[_0x2aae('0x18')][_0x2aae('0x19')]);return _0x48db15(_0x132d11[_0x2aae('0x18')][_0x2aae('0x19')]);}logger[_0x2aae('0x18')](_0x2aae('0x13'),_0x6db707,_0x132d11[_0x2aae('0x18')][_0x2aae('0x19')]);return _0x63158f(_0x132d11[_0x2aae('0x18')][_0x2aae('0x19')]);}else{logger[_0x2aae('0x12')]('SmsAccount,\x20%s,\x20%s',_0x6db707,_0x2aae('0x14'));_0x63158f(_0x132d11['result'][_0x2aae('0x19')]);}})[_0x2aae('0x1a')](function(_0x33c1d7){logger[_0x2aae('0x18')]('SmsAccount,\x20%s,\x20%s',_0x6db707,_0x33c1d7);_0x48db15(_0x33c1d7);});});}exports[_0x2aae('0x1b')]=function(_0x1c093f){var _0x441449=this;return new Promise(function(_0xb60d4f,_0x4445b5){return db[_0x2aae('0x1c')][_0x2aae('0x1d')]({'raw':_0x1c093f['options']?_0x1c093f['options'][_0x2aae('0x1e')]===undefined?!![]:![]:!![],'where':_0x1c093f[_0x2aae('0x1f')]?_0x1c093f[_0x2aae('0x1f')][_0x2aae('0x20')]||null:null,'attributes':_0x1c093f[_0x2aae('0x1f')]?_0x1c093f[_0x2aae('0x1f')]['attributes']||null:null,'include':_0x1c093f['options']?_0x1c093f[_0x2aae('0x1f')][_0x2aae('0x21')]?_[_0x2aae('0x22')](_0x1c093f[_0x2aae('0x1f')]['include'],function(_0x3691c8){return{'model':db[_0x3691c8[_0x2aae('0x23')]],'as':_0x3691c8['as'],'attributes':_0x3691c8[_0x2aae('0x24')],'include':_0x3691c8[_0x2aae('0x21')]?_[_0x2aae('0x22')](_0x3691c8['include'],function(_0x44f040){return{'model':db[_0x44f040[_0x2aae('0x23')]],'as':_0x44f040['as'],'attributes':_0x44f040[_0x2aae('0x24')],'include':_0x44f040[_0x2aae('0x21')]?_['map'](_0x44f040[_0x2aae('0x21')],function(_0x54aeee){return{'model':db[_0x54aeee[_0x2aae('0x23')]],'as':_0x54aeee['as'],'attributes':_0x54aeee['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x2a36d0){logger['info']('ShowSmsAccount',_0x1c093f);logger[_0x2aae('0x15')](_0x2aae('0x1b'),_0x1c093f,JSON[_0x2aae('0x16')](_0x2a36d0));_0xb60d4f(_0x2a36d0);})[_0x2aae('0x1a')](function(_0x553be7){logger[_0x2aae('0x18')]('ShowSmsAccount',_0x553be7[_0x2aae('0x19')],_0x1c093f);_0x4445b5(_0x441449[_0x2aae('0x18')](0x1f4,_0x553be7[_0x2aae('0x19')]));});});};