Built motion from commit 753c950e.|2.5.42
[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 _0xf190=['redis','localhost','request','then','info','SmsAccount,\x20%s,\x20%s','debug','SmsAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','request\x20sent','result','catch','SmsAccount','options','raw','attributes','include','map','model','ShowSmsAccount','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http'];(function(_0x447c82,_0x407de3){var _0x5429aa=function(_0x5b5415){while(--_0x5b5415){_0x447c82['push'](_0x447c82['shift']());}};_0x5429aa(++_0x407de3);}(_0xf190,0x7c));var _0x0f19=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xf190[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0x0f19('0x0'));var util=require(_0x0f19('0x1'));var moment=require(_0x0f19('0x2'));var BPromise=require(_0x0f19('0x3'));var rs=require(_0x0f19('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x0f19('0x5'))['db'];var utils=require(_0x0f19('0x6'));var logger=require(_0x0f19('0x7'))(_0x0f19('0x8'));var config=require(_0x0f19('0x9'));var jayson=require('jayson/promise');var client=jayson[_0x0f19('0xa')][_0x0f19('0xb')]({'port':0x232a});config[_0x0f19('0xc')]=_['defaults'](config[_0x0f19('0xc')],{'host':_0x0f19('0xd'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x0f19('0xc')]));require('./smsAccount.socket')['register'](socket);function respondWithRpcPromise(_0x6d8103,_0x4ccfeb,_0x275c25){return new BPromise(function(_0xdeb202,_0x45bc3b){return client[_0x0f19('0xe')](_0x6d8103,_0x275c25)[_0x0f19('0xf')](function(_0x233903){logger[_0x0f19('0x10')](_0x0f19('0x11'),_0x4ccfeb,'request\x20sent');logger[_0x0f19('0x12')](_0x0f19('0x13'),_0x4ccfeb,'request\x20sent',JSON[_0x0f19('0x14')](_0x233903));if(_0x233903['error']){if(_0x233903[_0x0f19('0x15')]['code']===0x1f4){logger[_0x0f19('0x15')]('SmsAccount,\x20%s,\x20%s',_0x4ccfeb,_0x233903[_0x0f19('0x15')][_0x0f19('0x16')]);return _0x45bc3b(_0x233903['error']['message']);}logger[_0x0f19('0x15')](_0x0f19('0x11'),_0x4ccfeb,_0x233903['error']['message']);return _0xdeb202(_0x233903[_0x0f19('0x15')]['message']);}else{logger[_0x0f19('0x10')](_0x0f19('0x11'),_0x4ccfeb,_0x0f19('0x17'));_0xdeb202(_0x233903[_0x0f19('0x18')][_0x0f19('0x16')]);}})[_0x0f19('0x19')](function(_0x26a11d){logger[_0x0f19('0x15')]('SmsAccount,\x20%s,\x20%s',_0x4ccfeb,_0x26a11d);_0x45bc3b(_0x26a11d);});});}exports['ShowSmsAccount']=function(_0x469005){var _0x3b101f=this;return new Promise(function(_0x6ef4d,_0x5e3338){return db[_0x0f19('0x1a')]['find']({'raw':_0x469005[_0x0f19('0x1b')]?_0x469005[_0x0f19('0x1b')][_0x0f19('0x1c')]===undefined?!![]:![]:!![],'where':_0x469005[_0x0f19('0x1b')]?_0x469005[_0x0f19('0x1b')]['where']||null:null,'attributes':_0x469005['options']?_0x469005['options'][_0x0f19('0x1d')]||null:null,'include':_0x469005[_0x0f19('0x1b')]?_0x469005[_0x0f19('0x1b')][_0x0f19('0x1e')]?_[_0x0f19('0x1f')](_0x469005[_0x0f19('0x1b')]['include'],function(_0x5b3f2d){return{'model':db[_0x5b3f2d['model']],'as':_0x5b3f2d['as'],'attributes':_0x5b3f2d[_0x0f19('0x1d')],'include':_0x5b3f2d[_0x0f19('0x1e')]?_[_0x0f19('0x1f')](_0x5b3f2d[_0x0f19('0x1e')],function(_0x1cfd48){return{'model':db[_0x1cfd48[_0x0f19('0x20')]],'as':_0x1cfd48['as'],'attributes':_0x1cfd48[_0x0f19('0x1d')],'include':_0x1cfd48[_0x0f19('0x1e')]?_[_0x0f19('0x1f')](_0x1cfd48[_0x0f19('0x1e')],function(_0x4427f2){return{'model':db[_0x4427f2[_0x0f19('0x20')]],'as':_0x4427f2['as'],'attributes':_0x4427f2[_0x0f19('0x1d')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x6cd3ce){logger['info'](_0x0f19('0x21'),_0x469005);logger[_0x0f19('0x12')](_0x0f19('0x21'),_0x469005,JSON[_0x0f19('0x14')](_0x6cd3ce));_0x6ef4d(_0x6cd3ce);})['catch'](function(_0x1ec392){logger['error']('ShowSmsAccount',_0x1ec392[_0x0f19('0x16')],_0x469005);_0x5e3338(_0x3b101f['error'](0x1f4,_0x1ec392[_0x0f19('0x16')]));});});};