Built motion from commit (unavailable).|2.5.17
[motion2.git] / server / api / whatsappInteraction / whatsappInteraction.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 _0x6d2b=['../../config/utils','rpc','../../config/environment','jayson/promise','http','redis','defaults','localhost','socket.io-emitter','./whatsappInteraction.socket','register','request','then','info','WhatsappInteraction,\x20%s,\x20%s','request\x20sent','error','message','result','update','body','options','raw','where','attributes','limit','UpdateWhatsappInteraction','stringify','AddTagsToWhatsappInteraction','WhatsappInteraction','find','addTags','ids','omit','AddTags','debug','catch','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb'];(function(_0x2b4411,_0x2625ed){var _0x8e41ef=function(_0x2aa8c1){while(--_0x2aa8c1){_0x2b4411['push'](_0x2b4411['shift']());}};_0x8e41ef(++_0x2625ed);}(_0x6d2b,0xfc));var _0xb6d2=function(_0x4d9cee,_0x2e1350){_0x4d9cee=_0x4d9cee-0x0;var _0x2fad5d=_0x6d2b[_0x4d9cee];return _0x2fad5d;};'use strict';var _=require(_0xb6d2('0x0'));var util=require('util');var moment=require(_0xb6d2('0x1'));var BPromise=require(_0xb6d2('0x2'));var rs=require(_0xb6d2('0x3'));var fs=require('fs');var Redis=require(_0xb6d2('0x4'));var db=require(_0xb6d2('0x5'))['db'];var utils=require(_0xb6d2('0x6'));var logger=require('../../config/logger')(_0xb6d2('0x7'));var config=require(_0xb6d2('0x8'));var jayson=require(_0xb6d2('0x9'));var client=jayson['client'][_0xb6d2('0xa')]({'port':0x232a});config[_0xb6d2('0xb')]=_[_0xb6d2('0xc')](config[_0xb6d2('0xb')],{'host':_0xb6d2('0xd'),'port':0x18eb});var socket=require(_0xb6d2('0xe'))(new Redis(config[_0xb6d2('0xb')]));require(_0xb6d2('0xf'))[_0xb6d2('0x10')](socket);function respondWithRpcPromise(_0x574224,_0x80adf6,_0x4a6785){return new BPromise(function(_0x1ee731,_0x591f56){return client[_0xb6d2('0x11')](_0x574224,_0x4a6785)[_0xb6d2('0x12')](function(_0x48e145){logger[_0xb6d2('0x13')](_0xb6d2('0x14'),_0x80adf6,_0xb6d2('0x15'));logger['debug']('WhatsappInteraction,\x20%s,\x20%s,\x20%s',_0x80adf6,'request\x20sent',JSON['stringify'](_0x48e145));if(_0x48e145[_0xb6d2('0x16')]){if(_0x48e145[_0xb6d2('0x16')]['code']===0x1f4){logger[_0xb6d2('0x16')](_0xb6d2('0x14'),_0x80adf6,_0x48e145['error'][_0xb6d2('0x17')]);return _0x591f56(_0x48e145['error'][_0xb6d2('0x17')]);}logger['error']('WhatsappInteraction,\x20%s,\x20%s',_0x80adf6,_0x48e145['error'][_0xb6d2('0x17')]);return _0x1ee731(_0x48e145['error'][_0xb6d2('0x17')]);}else{logger[_0xb6d2('0x13')](_0xb6d2('0x14'),_0x80adf6,_0xb6d2('0x15'));_0x1ee731(_0x48e145[_0xb6d2('0x18')][_0xb6d2('0x17')]);}})['catch'](function(_0x178efc){logger[_0xb6d2('0x16')]('WhatsappInteraction,\x20%s,\x20%s',_0x80adf6,_0x178efc);_0x591f56(_0x178efc);});});}exports['UpdateWhatsappInteraction']=function(_0x39b189){var _0x53886d=this;return new Promise(function(_0x3e6b42,_0x45e4a3){return db['WhatsappInteraction'][_0xb6d2('0x19')](_0x39b189[_0xb6d2('0x1a')],{'raw':_0x39b189[_0xb6d2('0x1b')]?_0x39b189[_0xb6d2('0x1b')][_0xb6d2('0x1c')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x39b189[_0xb6d2('0x1b')]?_0x39b189['options'][_0xb6d2('0x1d')]||null:null,'attributes':_0x39b189['options']?_0x39b189[_0xb6d2('0x1b')][_0xb6d2('0x1e')]||null:null,'limit':_0x39b189[_0xb6d2('0x1b')]?_0x39b189['options'][_0xb6d2('0x1f')]||null:null})[_0xb6d2('0x12')](function(_0x43f3c6){logger['info'](_0xb6d2('0x20'),_0x39b189);logger['debug'](_0xb6d2('0x20'),_0x39b189,JSON[_0xb6d2('0x21')](_0x43f3c6));_0x3e6b42(_0x43f3c6);})['catch'](function(_0x46f37f){logger['error'](_0xb6d2('0x20'),_0x46f37f[_0xb6d2('0x17')],_0x39b189);_0x45e4a3(_0x53886d[_0xb6d2('0x16')](0x1f4,_0x46f37f[_0xb6d2('0x17')]));});});};exports[_0xb6d2('0x22')]=function(_0x151d63){return new Promise(function(_0xe92f9f,_0x29b464){return db[_0xb6d2('0x23')][_0xb6d2('0x24')]({'where':_0x151d63[_0xb6d2('0x1b')]?_0x151d63['options'][_0xb6d2('0x1d')]||null:null})[_0xb6d2('0x12')](function(_0x10b2de){if(_0x10b2de){return _0x10b2de[_0xb6d2('0x25')](_0x151d63[_0xb6d2('0x1a')][_0xb6d2('0x26')],_[_0xb6d2('0x27')](_0x151d63[_0xb6d2('0x1a')],[_0xb6d2('0x26'),'id'])||{});}})['spread'](function(_0x74c204){logger[_0xb6d2('0x13')](_0xb6d2('0x28'),_0x151d63);logger[_0xb6d2('0x29')](_0xb6d2('0x28'),_0x151d63,JSON[_0xb6d2('0x21')](_0x74c204));_0xe92f9f(_0x74c204);})[_0xb6d2('0x2a')](function(_0x34dda9){logger['error'](_0xb6d2('0x28'),_0x34dda9[_0xb6d2('0x17')],_0x151d63);_0x29b464(_this[_0xb6d2('0x16')](0x1f4,_0x34dda9[_0xb6d2('0x17')]));});});};