Built motion from commit (unavailable).|2.5.11
[motion2.git] / server / api / whatsappAccount / whatsappAccount.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 _0x9124=['../../mysqldb','rpc','../../config/environment','http','defaults','socket.io-emitter','redis','./whatsappAccount.socket','then','info','WhatsappAccount,\x20%s,\x20%s','request\x20sent','WhatsappAccount,\x20%s,\x20%s,\x20%s','error','message','result','catch','ShowWhatsappAccount','WhatsappAccount','find','options','raw','where','include','map','attributes','model','debug','stringify','lodash','util','bluebird','randomstring','ioredis'];(function(_0x40911a,_0x55ec99){var _0x27e8e3=function(_0x2ba910){while(--_0x2ba910){_0x40911a['push'](_0x40911a['shift']());}};_0x27e8e3(++_0x55ec99);}(_0x9124,0x83));var _0x4912=function(_0x9b1b91,_0x528d09){_0x9b1b91=_0x9b1b91-0x0;var _0x2782d5=_0x9124[_0x9b1b91];return _0x2782d5;};'use strict';var _=require(_0x4912('0x0'));var util=require(_0x4912('0x1'));var moment=require('moment');var BPromise=require(_0x4912('0x2'));var rs=require(_0x4912('0x3'));var fs=require('fs');var Redis=require(_0x4912('0x4'));var db=require(_0x4912('0x5'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x4912('0x6'));var config=require(_0x4912('0x7'));var jayson=require('jayson/promise');var client=jayson['client'][_0x4912('0x8')]({'port':0x232a});config['redis']=_[_0x4912('0x9')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x4912('0xa'))(new Redis(config[_0x4912('0xb')]));require(_0x4912('0xc'))['register'](socket);function respondWithRpcPromise(_0x227982,_0x2eaf21,_0x952b69){return new BPromise(function(_0x173088,_0x44ceeb){return client['request'](_0x227982,_0x952b69)[_0x4912('0xd')](function(_0xa11762){logger[_0x4912('0xe')](_0x4912('0xf'),_0x2eaf21,_0x4912('0x10'));logger['debug'](_0x4912('0x11'),_0x2eaf21,_0x4912('0x10'),JSON['stringify'](_0xa11762));if(_0xa11762['error']){if(_0xa11762[_0x4912('0x12')]['code']===0x1f4){logger[_0x4912('0x12')](_0x4912('0xf'),_0x2eaf21,_0xa11762[_0x4912('0x12')]['message']);return _0x44ceeb(_0xa11762[_0x4912('0x12')][_0x4912('0x13')]);}logger[_0x4912('0x12')](_0x4912('0xf'),_0x2eaf21,_0xa11762[_0x4912('0x12')][_0x4912('0x13')]);return _0x173088(_0xa11762[_0x4912('0x12')]['message']);}else{logger['info'](_0x4912('0xf'),_0x2eaf21,_0x4912('0x10'));_0x173088(_0xa11762[_0x4912('0x14')][_0x4912('0x13')]);}})[_0x4912('0x15')](function(_0x59e7da){logger[_0x4912('0x12')](_0x4912('0xf'),_0x2eaf21,_0x59e7da);_0x44ceeb(_0x59e7da);});});}exports[_0x4912('0x16')]=function(_0x4659b4){var _0x4cec9c=this;return new Promise(function(_0x1d6a9b,_0x498d19){return db[_0x4912('0x17')][_0x4912('0x18')]({'raw':_0x4659b4['options']?_0x4659b4[_0x4912('0x19')][_0x4912('0x1a')]===undefined?!![]:![]:!![],'where':_0x4659b4[_0x4912('0x19')]?_0x4659b4[_0x4912('0x19')][_0x4912('0x1b')]||null:null,'attributes':_0x4659b4['options']?_0x4659b4[_0x4912('0x19')]['attributes']||null:null,'include':_0x4659b4[_0x4912('0x19')]?_0x4659b4[_0x4912('0x19')][_0x4912('0x1c')]?_[_0x4912('0x1d')](_0x4659b4[_0x4912('0x19')][_0x4912('0x1c')],function(_0x9c5acd){return{'model':db[_0x9c5acd['model']],'as':_0x9c5acd['as'],'attributes':_0x9c5acd[_0x4912('0x1e')],'include':_0x9c5acd['include']?_[_0x4912('0x1d')](_0x9c5acd[_0x4912('0x1c')],function(_0x267764){return{'model':db[_0x267764[_0x4912('0x1f')]],'as':_0x267764['as'],'attributes':_0x267764[_0x4912('0x1e')],'include':_0x267764[_0x4912('0x1c')]?_[_0x4912('0x1d')](_0x267764[_0x4912('0x1c')],function(_0x326d9c){return{'model':db[_0x326d9c[_0x4912('0x1f')]],'as':_0x326d9c['as'],'attributes':_0x326d9c['attributes']};}):[]};}):[]};}):[]:[]})[_0x4912('0xd')](function(_0x4caea1){logger['info'](_0x4912('0x16'),_0x4659b4);logger[_0x4912('0x20')]('ShowWhatsappAccount',_0x4659b4,JSON[_0x4912('0x21')](_0x4caea1));_0x1d6a9b(_0x4caea1);})[_0x4912('0x15')](function(_0x52f0a6){logger[_0x4912('0x12')](_0x4912('0x16'),_0x52f0a6['message'],_0x4659b4);_0x498d19(_0x4cec9c[_0x4912('0x12')](0x1f4,_0x52f0a6[_0x4912('0x13')]));});});};