Built motion from commit (unavailable).|2.5.31
[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 _0x42cf=['map','model','debug','lodash','util','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','http','redis','defaults','socket.io-emitter','./whatsappAccount.socket','register','request','then','info','request\x20sent','error','code','message','WhatsappAccount,\x20%s,\x20%s','result','catch','ShowWhatsappAccount','WhatsappAccount','find','options','raw','where','attributes','include'];(function(_0x2b6da5,_0x1969a2){var _0x3ab9c2=function(_0x3bf4d1){while(--_0x3bf4d1){_0x2b6da5['push'](_0x2b6da5['shift']());}};_0x3ab9c2(++_0x1969a2);}(_0x42cf,0x123));var _0xf42c=function(_0x243b59,_0x3f9495){_0x243b59=_0x243b59-0x0;var _0x3e1676=_0x42cf[_0x243b59];return _0x3e1676;};'use strict';var _=require(_0xf42c('0x0'));var util=require(_0xf42c('0x1'));var moment=require('moment');var BPromise=require(_0xf42c('0x2'));var rs=require(_0xf42c('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xf42c('0x4'))['db'];var utils=require(_0xf42c('0x5'));var logger=require(_0xf42c('0x6'))(_0xf42c('0x7'));var config=require('../../config/environment');var jayson=require(_0xf42c('0x8'));var client=jayson['client'][_0xf42c('0x9')]({'port':0x232a});config[_0xf42c('0xa')]=_[_0xf42c('0xb')](config[_0xf42c('0xa')],{'host':'localhost','port':0x18eb});var socket=require(_0xf42c('0xc'))(new Redis(config['redis']));require(_0xf42c('0xd'))[_0xf42c('0xe')](socket);function respondWithRpcPromise(_0x184b0e,_0x785b65,_0x2939f9){return new BPromise(function(_0x1fb7cf,_0x57b4d8){return client[_0xf42c('0xf')](_0x184b0e,_0x2939f9)[_0xf42c('0x10')](function(_0x36d089){logger[_0xf42c('0x11')]('WhatsappAccount,\x20%s,\x20%s',_0x785b65,_0xf42c('0x12'));logger['debug']('WhatsappAccount,\x20%s,\x20%s,\x20%s',_0x785b65,_0xf42c('0x12'),JSON['stringify'](_0x36d089));if(_0x36d089[_0xf42c('0x13')]){if(_0x36d089[_0xf42c('0x13')][_0xf42c('0x14')]===0x1f4){logger[_0xf42c('0x13')]('WhatsappAccount,\x20%s,\x20%s',_0x785b65,_0x36d089[_0xf42c('0x13')][_0xf42c('0x15')]);return _0x57b4d8(_0x36d089['error'][_0xf42c('0x15')]);}logger[_0xf42c('0x13')](_0xf42c('0x16'),_0x785b65,_0x36d089[_0xf42c('0x13')]['message']);return _0x1fb7cf(_0x36d089['error'][_0xf42c('0x15')]);}else{logger[_0xf42c('0x11')](_0xf42c('0x16'),_0x785b65,_0xf42c('0x12'));_0x1fb7cf(_0x36d089[_0xf42c('0x17')][_0xf42c('0x15')]);}})[_0xf42c('0x18')](function(_0x539e76){logger[_0xf42c('0x13')](_0xf42c('0x16'),_0x785b65,_0x539e76);_0x57b4d8(_0x539e76);});});}exports[_0xf42c('0x19')]=function(_0x4c5392){var _0x312ca5=this;return new Promise(function(_0x126466,_0x33bbcb){return db[_0xf42c('0x1a')][_0xf42c('0x1b')]({'raw':_0x4c5392[_0xf42c('0x1c')]?_0x4c5392[_0xf42c('0x1c')][_0xf42c('0x1d')]===undefined?!![]:![]:!![],'where':_0x4c5392[_0xf42c('0x1c')]?_0x4c5392[_0xf42c('0x1c')][_0xf42c('0x1e')]||null:null,'attributes':_0x4c5392[_0xf42c('0x1c')]?_0x4c5392[_0xf42c('0x1c')][_0xf42c('0x1f')]||null:null,'include':_0x4c5392['options']?_0x4c5392[_0xf42c('0x1c')][_0xf42c('0x20')]?_[_0xf42c('0x21')](_0x4c5392[_0xf42c('0x1c')][_0xf42c('0x20')],function(_0x495ff8){return{'model':db[_0x495ff8[_0xf42c('0x22')]],'as':_0x495ff8['as'],'attributes':_0x495ff8[_0xf42c('0x1f')],'include':_0x495ff8[_0xf42c('0x20')]?_[_0xf42c('0x21')](_0x495ff8[_0xf42c('0x20')],function(_0x280c7a){return{'model':db[_0x280c7a['model']],'as':_0x280c7a['as'],'attributes':_0x280c7a[_0xf42c('0x1f')],'include':_0x280c7a[_0xf42c('0x20')]?_[_0xf42c('0x21')](_0x280c7a[_0xf42c('0x20')],function(_0x5b8217){return{'model':db[_0x5b8217['model']],'as':_0x5b8217['as'],'attributes':_0x5b8217[_0xf42c('0x1f')]};}):[]};}):[]};}):[]:[]})[_0xf42c('0x10')](function(_0x21a422){logger[_0xf42c('0x11')]('ShowWhatsappAccount',_0x4c5392);logger[_0xf42c('0x23')](_0xf42c('0x19'),_0x4c5392,JSON['stringify'](_0x21a422));_0x126466(_0x21a422);})['catch'](function(_0x224847){logger['error']('ShowWhatsappAccount',_0x224847[_0xf42c('0x15')],_0x4c5392);_0x33bbcb(_0x312ca5['error'](0x1f4,_0x224847[_0xf42c('0x15')]));});});};