Built motion from commit da24aabd.|2.6.20
[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 _0x782f=['find','options','where','include','map','model','attributes','stringify','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','defaults','redis','localhost','socket.io-emitter','register','request','then','info','SmsAccount,\x20%s,\x20%s','request\x20sent','debug','SmsAccount,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','ShowSmsAccount','SmsAccount'];(function(_0x725a4c,_0x102507){var _0x37b2cc=function(_0x505fc9){while(--_0x505fc9){_0x725a4c['push'](_0x725a4c['shift']());}};_0x37b2cc(++_0x102507);}(_0x782f,0xec));var _0xf782=function(_0x2aa7d9,_0xc69c98){_0x2aa7d9=_0x2aa7d9-0x0;var _0x109308=_0x782f[_0x2aa7d9];return _0x109308;};'use strict';var _=require('lodash');var util=require(_0xf782('0x0'));var moment=require(_0xf782('0x1'));var BPromise=require(_0xf782('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xf782('0x3'));var db=require(_0xf782('0x4'))['db'];var utils=require(_0xf782('0x5'));var logger=require(_0xf782('0x6'))(_0xf782('0x7'));var config=require('../../config/environment');var jayson=require(_0xf782('0x8'));var client=jayson[_0xf782('0x9')][_0xf782('0xa')]({'port':0x232a});config['redis']=_[_0xf782('0xb')](config[_0xf782('0xc')],{'host':_0xf782('0xd'),'port':0x18eb});var socket=require(_0xf782('0xe'))(new Redis(config[_0xf782('0xc')]));require('./smsAccount.socket')[_0xf782('0xf')](socket);function respondWithRpcPromise(_0x641688,_0x327515,_0x45b764){return new BPromise(function(_0x4c87e5,_0x70153){return client[_0xf782('0x10')](_0x641688,_0x45b764)[_0xf782('0x11')](function(_0x41c9a){logger[_0xf782('0x12')](_0xf782('0x13'),_0x327515,_0xf782('0x14'));logger[_0xf782('0x15')](_0xf782('0x16'),_0x327515,_0xf782('0x14'),JSON['stringify'](_0x41c9a));if(_0x41c9a['error']){if(_0x41c9a[_0xf782('0x17')][_0xf782('0x18')]===0x1f4){logger[_0xf782('0x17')]('SmsAccount,\x20%s,\x20%s',_0x327515,_0x41c9a['error']['message']);return _0x70153(_0x41c9a['error'][_0xf782('0x19')]);}logger['error'](_0xf782('0x13'),_0x327515,_0x41c9a[_0xf782('0x17')][_0xf782('0x19')]);return _0x4c87e5(_0x41c9a[_0xf782('0x17')][_0xf782('0x19')]);}else{logger[_0xf782('0x12')](_0xf782('0x13'),_0x327515,_0xf782('0x14'));_0x4c87e5(_0x41c9a[_0xf782('0x1a')][_0xf782('0x19')]);}})[_0xf782('0x1b')](function(_0x359586){logger[_0xf782('0x17')](_0xf782('0x13'),_0x327515,_0x359586);_0x70153(_0x359586);});});}exports[_0xf782('0x1c')]=function(_0x2c0b56){var _0x42f092=this;return new Promise(function(_0x191dc0,_0x4b4c50){return db[_0xf782('0x1d')][_0xf782('0x1e')]({'raw':_0x2c0b56[_0xf782('0x1f')]?_0x2c0b56['options']['raw']===undefined?!![]:![]:!![],'where':_0x2c0b56[_0xf782('0x1f')]?_0x2c0b56['options'][_0xf782('0x20')]||null:null,'attributes':_0x2c0b56[_0xf782('0x1f')]?_0x2c0b56[_0xf782('0x1f')]['attributes']||null:null,'include':_0x2c0b56[_0xf782('0x1f')]?_0x2c0b56['options'][_0xf782('0x21')]?_[_0xf782('0x22')](_0x2c0b56[_0xf782('0x1f')]['include'],function(_0xd9d066){return{'model':db[_0xd9d066[_0xf782('0x23')]],'as':_0xd9d066['as'],'attributes':_0xd9d066[_0xf782('0x24')],'include':_0xd9d066[_0xf782('0x21')]?_['map'](_0xd9d066[_0xf782('0x21')],function(_0x564420){return{'model':db[_0x564420[_0xf782('0x23')]],'as':_0x564420['as'],'attributes':_0x564420[_0xf782('0x24')],'include':_0x564420[_0xf782('0x21')]?_['map'](_0x564420[_0xf782('0x21')],function(_0xda1326){return{'model':db[_0xda1326[_0xf782('0x23')]],'as':_0xda1326['as'],'attributes':_0xda1326[_0xf782('0x24')]};}):[]};}):[]};}):[]:[]})[_0xf782('0x11')](function(_0x5b880d){logger['info'](_0xf782('0x1c'),_0x2c0b56);logger['debug']('ShowSmsAccount',_0x2c0b56,JSON[_0xf782('0x25')](_0x5b880d));_0x191dc0(_0x5b880d);})[_0xf782('0x1b')](function(_0x20cbc5){logger[_0xf782('0x17')](_0xf782('0x1c'),_0x20cbc5[_0xf782('0x19')],_0x2c0b56);_0x4b4c50(_0x42f092[_0xf782('0x17')](0x1f4,_0x20cbc5['message']));});});};