Built motion from commit (unavailable).|2.5.4
[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 _0xce89=['info','WhatsappAccount,\x20%s,\x20%s','request\x20sent','debug','WhatsappAccount,\x20%s,\x20%s,\x20%s','error','code','message','catch','ShowWhatsappAccount','find','options','where','include','attributes','map','model','stringify','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','jayson/promise','client','defaults','socket.io-emitter','redis','./whatsappAccount.socket','register','then'];(function(_0x46bae9,_0x56d783){var _0x6d2d94=function(_0x1a7f2e){while(--_0x1a7f2e){_0x46bae9['push'](_0x46bae9['shift']());}};_0x6d2d94(++_0x56d783);}(_0xce89,0x1aa));var _0x9ce8=function(_0x422baa,_0x98d34a){_0x422baa=_0x422baa-0x0;var _0x31c810=_0xce89[_0x422baa];return _0x31c810;};'use strict';var _=require(_0x9ce8('0x0'));var util=require(_0x9ce8('0x1'));var moment=require(_0x9ce8('0x2'));var BPromise=require(_0x9ce8('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x9ce8('0x4'));var db=require(_0x9ce8('0x5'))['db'];var utils=require(_0x9ce8('0x6'));var logger=require(_0x9ce8('0x7'))('rpc');var config=require('../../config/environment');var jayson=require(_0x9ce8('0x8'));var client=jayson[_0x9ce8('0x9')]['http']({'port':0x232a});config['redis']=_[_0x9ce8('0xa')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x9ce8('0xb'))(new Redis(config[_0x9ce8('0xc')]));require(_0x9ce8('0xd'))[_0x9ce8('0xe')](socket);function respondWithRpcPromise(_0x4487b2,_0x3187a5,_0x1ee577){return new BPromise(function(_0x1cf1ad,_0x4b08a1){return client['request'](_0x4487b2,_0x1ee577)[_0x9ce8('0xf')](function(_0x4ac7ff){logger[_0x9ce8('0x10')](_0x9ce8('0x11'),_0x3187a5,_0x9ce8('0x12'));logger[_0x9ce8('0x13')](_0x9ce8('0x14'),_0x3187a5,_0x9ce8('0x12'),JSON['stringify'](_0x4ac7ff));if(_0x4ac7ff[_0x9ce8('0x15')]){if(_0x4ac7ff[_0x9ce8('0x15')][_0x9ce8('0x16')]===0x1f4){logger[_0x9ce8('0x15')](_0x9ce8('0x11'),_0x3187a5,_0x4ac7ff[_0x9ce8('0x15')]['message']);return _0x4b08a1(_0x4ac7ff[_0x9ce8('0x15')][_0x9ce8('0x17')]);}logger['error'](_0x9ce8('0x11'),_0x3187a5,_0x4ac7ff[_0x9ce8('0x15')][_0x9ce8('0x17')]);return _0x1cf1ad(_0x4ac7ff['error'][_0x9ce8('0x17')]);}else{logger[_0x9ce8('0x10')](_0x9ce8('0x11'),_0x3187a5,_0x9ce8('0x12'));_0x1cf1ad(_0x4ac7ff['result'][_0x9ce8('0x17')]);}})[_0x9ce8('0x18')](function(_0x1e2f74){logger[_0x9ce8('0x15')]('WhatsappAccount,\x20%s,\x20%s',_0x3187a5,_0x1e2f74);_0x4b08a1(_0x1e2f74);});});}exports[_0x9ce8('0x19')]=function(_0x5c7264){var _0x2d93e9=this;return new Promise(function(_0x34759e,_0x4876da){return db['WhatsappAccount'][_0x9ce8('0x1a')]({'raw':_0x5c7264[_0x9ce8('0x1b')]?_0x5c7264[_0x9ce8('0x1b')]['raw']===undefined?!![]:![]:!![],'where':_0x5c7264[_0x9ce8('0x1b')]?_0x5c7264[_0x9ce8('0x1b')][_0x9ce8('0x1c')]||null:null,'attributes':_0x5c7264[_0x9ce8('0x1b')]?_0x5c7264[_0x9ce8('0x1b')]['attributes']||null:null,'include':_0x5c7264[_0x9ce8('0x1b')]?_0x5c7264[_0x9ce8('0x1b')][_0x9ce8('0x1d')]?_['map'](_0x5c7264[_0x9ce8('0x1b')][_0x9ce8('0x1d')],function(_0x5dd500){return{'model':db[_0x5dd500['model']],'as':_0x5dd500['as'],'attributes':_0x5dd500[_0x9ce8('0x1e')],'include':_0x5dd500['include']?_[_0x9ce8('0x1f')](_0x5dd500[_0x9ce8('0x1d')],function(_0x4e320a){return{'model':db[_0x4e320a[_0x9ce8('0x20')]],'as':_0x4e320a['as'],'attributes':_0x4e320a['attributes'],'include':_0x4e320a[_0x9ce8('0x1d')]?_[_0x9ce8('0x1f')](_0x4e320a['include'],function(_0x35c3a9){return{'model':db[_0x35c3a9[_0x9ce8('0x20')]],'as':_0x35c3a9['as'],'attributes':_0x35c3a9[_0x9ce8('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x9ce8('0xf')](function(_0x32e939){logger[_0x9ce8('0x10')]('ShowWhatsappAccount',_0x5c7264);logger[_0x9ce8('0x13')](_0x9ce8('0x19'),_0x5c7264,JSON[_0x9ce8('0x21')](_0x32e939));_0x34759e(_0x32e939);})['catch'](function(_0xac87be){logger[_0x9ce8('0x15')](_0x9ce8('0x19'),_0xac87be['message'],_0x5c7264);_0x4876da(_0x2d93e9[_0x9ce8('0x15')](0x1f4,_0xac87be[_0x9ce8('0x17')]));});});};