Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / chatInteraction / chatInteraction.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 _0x2e38=['ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','localhost','socket.io-emitter','./chatInteraction.socket','register','request','ChatInteraction,\x20%s,\x20%s','request\x20sent','debug','ChatInteraction,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','UpdateChatInteraction','ChatInteraction','update','options','raw','where','attributes','then','AddTagsToChatInteraction','addTags','body','ids','omit','spread','AddTags','lodash','util','bluebird','randomstring'];(function(_0x456f1c,_0x4453d5){var _0x51918c=function(_0x12ce55){while(--_0x12ce55){_0x456f1c['push'](_0x456f1c['shift']());}};_0x51918c(++_0x4453d5);}(_0x2e38,0x1be));var _0x82e3=function(_0x4c9ee6,_0x90caf9){_0x4c9ee6=_0x4c9ee6-0x0;var _0x130ee8=_0x2e38[_0x4c9ee6];return _0x130ee8;};'use strict';var _=require(_0x82e3('0x0'));var util=require(_0x82e3('0x1'));var moment=require('moment');var BPromise=require(_0x82e3('0x2'));var rs=require(_0x82e3('0x3'));var fs=require('fs');var Redis=require(_0x82e3('0x4'));var db=require(_0x82e3('0x5'))['db'];var utils=require(_0x82e3('0x6'));var logger=require(_0x82e3('0x7'))(_0x82e3('0x8'));var config=require(_0x82e3('0x9'));var jayson=require(_0x82e3('0xa'));var client=jayson[_0x82e3('0xb')][_0x82e3('0xc')]({'port':0x232a});config[_0x82e3('0xd')]=_['defaults'](config[_0x82e3('0xd')],{'host':_0x82e3('0xe'),'port':0x18eb});var socket=require(_0x82e3('0xf'))(new Redis(config[_0x82e3('0xd')]));require(_0x82e3('0x10'))[_0x82e3('0x11')](socket);function respondWithRpcPromise(_0xd16f14,_0x40bf12,_0x56e175){return new BPromise(function(_0x47290,_0x4e8cd4){return client[_0x82e3('0x12')](_0xd16f14,_0x56e175)['then'](function(_0x46dfc3){logger['info'](_0x82e3('0x13'),_0x40bf12,_0x82e3('0x14'));logger[_0x82e3('0x15')](_0x82e3('0x16'),_0x40bf12,_0x82e3('0x14'),JSON[_0x82e3('0x17')](_0x46dfc3));if(_0x46dfc3[_0x82e3('0x18')]){if(_0x46dfc3[_0x82e3('0x18')][_0x82e3('0x19')]===0x1f4){logger['error'](_0x82e3('0x13'),_0x40bf12,_0x46dfc3[_0x82e3('0x18')][_0x82e3('0x1a')]);return _0x4e8cd4(_0x46dfc3[_0x82e3('0x18')][_0x82e3('0x1a')]);}logger[_0x82e3('0x18')](_0x82e3('0x13'),_0x40bf12,_0x46dfc3[_0x82e3('0x18')][_0x82e3('0x1a')]);return _0x47290(_0x46dfc3[_0x82e3('0x18')]['message']);}else{logger[_0x82e3('0x1b')](_0x82e3('0x13'),_0x40bf12,'request\x20sent');_0x47290(_0x46dfc3[_0x82e3('0x1c')]['message']);}})[_0x82e3('0x1d')](function(_0x3781c5){logger[_0x82e3('0x18')](_0x82e3('0x13'),_0x40bf12,_0x3781c5);_0x4e8cd4(_0x3781c5);});});}exports[_0x82e3('0x1e')]=function(_0x707dc8){var _0x470711=this;return new Promise(function(_0x28bfba,_0x2bfc32){return db[_0x82e3('0x1f')][_0x82e3('0x20')](_0x707dc8['body'],{'raw':_0x707dc8[_0x82e3('0x21')]?_0x707dc8[_0x82e3('0x21')][_0x82e3('0x22')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x707dc8[_0x82e3('0x21')]?_0x707dc8[_0x82e3('0x21')][_0x82e3('0x23')]||null:null,'attributes':_0x707dc8[_0x82e3('0x21')]?_0x707dc8[_0x82e3('0x21')][_0x82e3('0x24')]||null:null,'limit':_0x707dc8['options']?_0x707dc8[_0x82e3('0x21')]['limit']||null:null})[_0x82e3('0x25')](function(_0x45756c){logger[_0x82e3('0x1b')]('UpdateChatInteraction',_0x707dc8);logger[_0x82e3('0x15')](_0x82e3('0x1e'),_0x707dc8,JSON['stringify'](_0x45756c));_0x28bfba(_0x45756c);})['catch'](function(_0x12449b){logger[_0x82e3('0x18')](_0x82e3('0x1e'),_0x12449b['message'],_0x707dc8);_0x2bfc32(_0x470711['error'](0x1f4,_0x12449b[_0x82e3('0x1a')]));});});};exports[_0x82e3('0x26')]=function(_0x3efef6){return new Promise(function(_0x49da7a,_0x43918b){return db[_0x82e3('0x1f')]['find']({'where':_0x3efef6[_0x82e3('0x21')]?_0x3efef6['options'][_0x82e3('0x23')]||null:null})[_0x82e3('0x25')](function(_0x33b764){if(_0x33b764){return _0x33b764[_0x82e3('0x27')](_0x3efef6[_0x82e3('0x28')][_0x82e3('0x29')],_[_0x82e3('0x2a')](_0x3efef6[_0x82e3('0x28')],[_0x82e3('0x29'),'id'])||{});}})[_0x82e3('0x2b')](function(_0x37d4dc){logger['info'](_0x82e3('0x2c'),_0x3efef6);logger[_0x82e3('0x15')]('AddTags',_0x3efef6,JSON[_0x82e3('0x17')](_0x37d4dc));_0x49da7a(_0x37d4dc);})[_0x82e3('0x1d')](function(_0x435c29){logger[_0x82e3('0x18')](_0x82e3('0x2c'),_0x435c29['message'],_0x3efef6);_0x43918b(_this[_0x82e3('0x18')](0x1f4,_0x435c29['message']));});});};