Built motion from commit (unavailable).|2.5.4
[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 _0xc47f=['ids','omit','spread','AddTags','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','redis','localhost','socket.io-emitter','./whatsappInteraction.socket','register','request','then','request\x20sent','debug','stringify','error','code','WhatsappInteraction,\x20%s,\x20%s','message','info','result','catch','WhatsappInteraction','update','body','options','raw','attributes','UpdateWhatsappInteraction','AddTagsToWhatsappInteraction','find','addTags'];(function(_0x5d8987,_0x14d054){var _0x2997eb=function(_0x56f92a){while(--_0x56f92a){_0x5d8987['push'](_0x5d8987['shift']());}};_0x2997eb(++_0x14d054);}(_0xc47f,0x15c));var _0xfc47=function(_0x51020b,_0x38c2c7){_0x51020b=_0x51020b-0x0;var _0x371e47=_0xc47f[_0x51020b];return _0x371e47;};'use strict';var _=require(_0xfc47('0x0'));var util=require(_0xfc47('0x1'));var moment=require(_0xfc47('0x2'));var BPromise=require('bluebird');var rs=require(_0xfc47('0x3'));var fs=require('fs');var Redis=require(_0xfc47('0x4'));var db=require(_0xfc47('0x5'))['db'];var utils=require(_0xfc47('0x6'));var logger=require('../../config/logger')(_0xfc47('0x7'));var config=require(_0xfc47('0x8'));var jayson=require(_0xfc47('0x9'));var client=jayson[_0xfc47('0xa')][_0xfc47('0xb')]({'port':0x232a});config[_0xfc47('0xc')]=_['defaults'](config[_0xfc47('0xc')],{'host':_0xfc47('0xd'),'port':0x18eb});var socket=require(_0xfc47('0xe'))(new Redis(config[_0xfc47('0xc')]));require(_0xfc47('0xf'))[_0xfc47('0x10')](socket);function respondWithRpcPromise(_0x494365,_0xc2af23,_0x551418){return new BPromise(function(_0x3d6322,_0x416cde){return client[_0xfc47('0x11')](_0x494365,_0x551418)[_0xfc47('0x12')](function(_0x1e3e77){logger['info']('WhatsappInteraction,\x20%s,\x20%s',_0xc2af23,_0xfc47('0x13'));logger[_0xfc47('0x14')]('WhatsappInteraction,\x20%s,\x20%s,\x20%s',_0xc2af23,_0xfc47('0x13'),JSON[_0xfc47('0x15')](_0x1e3e77));if(_0x1e3e77['error']){if(_0x1e3e77[_0xfc47('0x16')][_0xfc47('0x17')]===0x1f4){logger['error'](_0xfc47('0x18'),_0xc2af23,_0x1e3e77[_0xfc47('0x16')][_0xfc47('0x19')]);return _0x416cde(_0x1e3e77[_0xfc47('0x16')][_0xfc47('0x19')]);}logger[_0xfc47('0x16')](_0xfc47('0x18'),_0xc2af23,_0x1e3e77[_0xfc47('0x16')]['message']);return _0x3d6322(_0x1e3e77['error'][_0xfc47('0x19')]);}else{logger[_0xfc47('0x1a')](_0xfc47('0x18'),_0xc2af23,_0xfc47('0x13'));_0x3d6322(_0x1e3e77[_0xfc47('0x1b')][_0xfc47('0x19')]);}})[_0xfc47('0x1c')](function(_0x98cc94){logger[_0xfc47('0x16')]('WhatsappInteraction,\x20%s,\x20%s',_0xc2af23,_0x98cc94);_0x416cde(_0x98cc94);});});}exports['UpdateWhatsappInteraction']=function(_0xe8e392){var _0x5a34da=this;return new Promise(function(_0x997818,_0x2a9359){return db[_0xfc47('0x1d')][_0xfc47('0x1e')](_0xe8e392[_0xfc47('0x1f')],{'raw':_0xe8e392['options']?_0xe8e392[_0xfc47('0x20')][_0xfc47('0x21')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0xe8e392[_0xfc47('0x20')]?_0xe8e392[_0xfc47('0x20')]['where']||null:null,'attributes':_0xe8e392[_0xfc47('0x20')]?_0xe8e392['options'][_0xfc47('0x22')]||null:null,'limit':_0xe8e392[_0xfc47('0x20')]?_0xe8e392[_0xfc47('0x20')]['limit']||null:null})[_0xfc47('0x12')](function(_0x323289){logger[_0xfc47('0x1a')]('UpdateWhatsappInteraction',_0xe8e392);logger[_0xfc47('0x14')](_0xfc47('0x23'),_0xe8e392,JSON[_0xfc47('0x15')](_0x323289));_0x997818(_0x323289);})[_0xfc47('0x1c')](function(_0x26f35d){logger[_0xfc47('0x16')]('UpdateWhatsappInteraction',_0x26f35d[_0xfc47('0x19')],_0xe8e392);_0x2a9359(_0x5a34da['error'](0x1f4,_0x26f35d[_0xfc47('0x19')]));});});};exports[_0xfc47('0x24')]=function(_0x5a26e0){return new Promise(function(_0x54f6d8,_0x276b61){return db[_0xfc47('0x1d')][_0xfc47('0x25')]({'where':_0x5a26e0[_0xfc47('0x20')]?_0x5a26e0[_0xfc47('0x20')]['where']||null:null})['then'](function(_0x453c1f){if(_0x453c1f){return _0x453c1f[_0xfc47('0x26')](_0x5a26e0[_0xfc47('0x1f')][_0xfc47('0x27')],_[_0xfc47('0x28')](_0x5a26e0[_0xfc47('0x1f')],[_0xfc47('0x27'),'id'])||{});}})[_0xfc47('0x29')](function(_0x1ccb16){logger['info']('AddTags',_0x5a26e0);logger[_0xfc47('0x14')](_0xfc47('0x2a'),_0x5a26e0,JSON[_0xfc47('0x15')](_0x1ccb16));_0x54f6d8(_0x1ccb16);})[_0xfc47('0x1c')](function(_0x5b379a){logger['error'](_0xfc47('0x2a'),_0x5b379a[_0xfc47('0x19')],_0x5a26e0);_0x276b61(_this['error'](0x1f4,_0x5b379a[_0xfc47('0x19')]));});});};