Built motion from commit 55091a5c.|2.6.30
[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 _0xfc37=['result','catch','ShowWhatsappAccount','WhatsappAccount','find','options','raw','where','attributes','include','model','map','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./whatsappAccount.socket','register','then','info','request\x20sent','debug','WhatsappAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','WhatsappAccount,\x20%s,\x20%s','message'];(function(_0x19c169,_0x2530f2){var _0x231ee7=function(_0x2f97f1){while(--_0x2f97f1){_0x19c169['push'](_0x19c169['shift']());}};_0x231ee7(++_0x2530f2);}(_0xfc37,0x17d));var _0x7fc3=function(_0xcf8676,_0x1407bb){_0xcf8676=_0xcf8676-0x0;var _0x244c49=_0xfc37[_0xcf8676];return _0x244c49;};'use strict';var _=require(_0x7fc3('0x0'));var util=require(_0x7fc3('0x1'));var moment=require(_0x7fc3('0x2'));var BPromise=require(_0x7fc3('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x7fc3('0x4'));var db=require(_0x7fc3('0x5'))['db'];var utils=require(_0x7fc3('0x6'));var logger=require(_0x7fc3('0x7'))(_0x7fc3('0x8'));var config=require(_0x7fc3('0x9'));var jayson=require(_0x7fc3('0xa'));var client=jayson[_0x7fc3('0xb')][_0x7fc3('0xc')]({'port':0x232a});config[_0x7fc3('0xd')]=_[_0x7fc3('0xe')](config[_0x7fc3('0xd')],{'host':_0x7fc3('0xf'),'port':0x18eb});var socket=require(_0x7fc3('0x10'))(new Redis(config[_0x7fc3('0xd')]));require(_0x7fc3('0x11'))[_0x7fc3('0x12')](socket);function respondWithRpcPromise(_0x15a206,_0x34e386,_0x4c04b8){return new BPromise(function(_0x1eeac0,_0x19e496){return client['request'](_0x15a206,_0x4c04b8)[_0x7fc3('0x13')](function(_0x1b7af6){logger[_0x7fc3('0x14')]('WhatsappAccount,\x20%s,\x20%s',_0x34e386,_0x7fc3('0x15'));logger[_0x7fc3('0x16')](_0x7fc3('0x17'),_0x34e386,_0x7fc3('0x15'),JSON[_0x7fc3('0x18')](_0x1b7af6));if(_0x1b7af6[_0x7fc3('0x19')]){if(_0x1b7af6[_0x7fc3('0x19')][_0x7fc3('0x1a')]===0x1f4){logger['error'](_0x7fc3('0x1b'),_0x34e386,_0x1b7af6[_0x7fc3('0x19')][_0x7fc3('0x1c')]);return _0x19e496(_0x1b7af6['error'][_0x7fc3('0x1c')]);}logger[_0x7fc3('0x19')](_0x7fc3('0x1b'),_0x34e386,_0x1b7af6[_0x7fc3('0x19')]['message']);return _0x1eeac0(_0x1b7af6[_0x7fc3('0x19')][_0x7fc3('0x1c')]);}else{logger['info'](_0x7fc3('0x1b'),_0x34e386,'request\x20sent');_0x1eeac0(_0x1b7af6[_0x7fc3('0x1d')]['message']);}})[_0x7fc3('0x1e')](function(_0x3c9561){logger[_0x7fc3('0x19')](_0x7fc3('0x1b'),_0x34e386,_0x3c9561);_0x19e496(_0x3c9561);});});}exports[_0x7fc3('0x1f')]=function(_0x193681){var _0x76310a=this;return new Promise(function(_0x9fe316,_0x1c49ba){return db[_0x7fc3('0x20')][_0x7fc3('0x21')]({'raw':_0x193681['options']?_0x193681[_0x7fc3('0x22')][_0x7fc3('0x23')]===undefined?!![]:![]:!![],'where':_0x193681[_0x7fc3('0x22')]?_0x193681[_0x7fc3('0x22')][_0x7fc3('0x24')]||null:null,'attributes':_0x193681[_0x7fc3('0x22')]?_0x193681[_0x7fc3('0x22')][_0x7fc3('0x25')]||null:null,'include':_0x193681[_0x7fc3('0x22')]?_0x193681[_0x7fc3('0x22')]['include']?_['map'](_0x193681[_0x7fc3('0x22')][_0x7fc3('0x26')],function(_0x15eb2f){return{'model':db[_0x15eb2f[_0x7fc3('0x27')]],'as':_0x15eb2f['as'],'attributes':_0x15eb2f[_0x7fc3('0x25')],'include':_0x15eb2f['include']?_[_0x7fc3('0x28')](_0x15eb2f[_0x7fc3('0x26')],function(_0x386f9f){return{'model':db[_0x386f9f[_0x7fc3('0x27')]],'as':_0x386f9f['as'],'attributes':_0x386f9f['attributes'],'include':_0x386f9f[_0x7fc3('0x26')]?_[_0x7fc3('0x28')](_0x386f9f[_0x7fc3('0x26')],function(_0x2eb0b3){return{'model':db[_0x2eb0b3[_0x7fc3('0x27')]],'as':_0x2eb0b3['as'],'attributes':_0x2eb0b3[_0x7fc3('0x25')]};}):[]};}):[]};}):[]:[]})[_0x7fc3('0x13')](function(_0xc57acc){logger[_0x7fc3('0x14')](_0x7fc3('0x1f'),_0x193681);logger[_0x7fc3('0x16')](_0x7fc3('0x1f'),_0x193681,JSON[_0x7fc3('0x18')](_0xc57acc));_0x9fe316(_0xc57acc);})[_0x7fc3('0x1e')](function(_0x5ead5c){logger[_0x7fc3('0x19')](_0x7fc3('0x1f'),_0x5ead5c['message'],_0x193681);_0x1c49ba(_0x76310a[_0x7fc3('0x19')](0x1f4,_0x5ead5c[_0x7fc3('0x1c')]));});});};