Built motion from commit (unavailable).|2.5.31
[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 _0x5ac3=['request','then','ChatInteraction,\x20%s,\x20%s','request\x20sent','ChatInteraction,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','UpdateChatInteraction','update','options','raw','limit','AddTagsToChatInteraction','find','where','addTags','body','ids','omit','AddTags','debug','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','socket.io-emitter','register'];(function(_0x29f0d7,_0x5bd0f0){var _0x8aee39=function(_0x19abba){while(--_0x19abba){_0x29f0d7['push'](_0x29f0d7['shift']());}};_0x8aee39(++_0x5bd0f0);}(_0x5ac3,0x11c));var _0x35ac=function(_0x13f206,_0x4c6c8e){_0x13f206=_0x13f206-0x0;var _0x29aaf1=_0x5ac3[_0x13f206];return _0x29aaf1;};'use strict';var _=require(_0x35ac('0x0'));var util=require('util');var moment=require(_0x35ac('0x1'));var BPromise=require(_0x35ac('0x2'));var rs=require(_0x35ac('0x3'));var fs=require('fs');var Redis=require(_0x35ac('0x4'));var db=require(_0x35ac('0x5'))['db'];var utils=require(_0x35ac('0x6'));var logger=require(_0x35ac('0x7'))(_0x35ac('0x8'));var config=require(_0x35ac('0x9'));var jayson=require(_0x35ac('0xa'));var client=jayson[_0x35ac('0xb')][_0x35ac('0xc')]({'port':0x232a});config[_0x35ac('0xd')]=_[_0x35ac('0xe')](config[_0x35ac('0xd')],{'host':'localhost','port':0x18eb});var socket=require(_0x35ac('0xf'))(new Redis(config['redis']));require('./chatInteraction.socket')[_0x35ac('0x10')](socket);function respondWithRpcPromise(_0x253cbc,_0x1fa3ef,_0x478033){return new BPromise(function(_0x4bb6e8,_0x281132){return client[_0x35ac('0x11')](_0x253cbc,_0x478033)[_0x35ac('0x12')](function(_0x357b71){logger['info'](_0x35ac('0x13'),_0x1fa3ef,_0x35ac('0x14'));logger['debug'](_0x35ac('0x15'),_0x1fa3ef,'request\x20sent',JSON[_0x35ac('0x16')](_0x357b71));if(_0x357b71[_0x35ac('0x17')]){if(_0x357b71[_0x35ac('0x17')][_0x35ac('0x18')]===0x1f4){logger[_0x35ac('0x17')](_0x35ac('0x13'),_0x1fa3ef,_0x357b71[_0x35ac('0x17')][_0x35ac('0x19')]);return _0x281132(_0x357b71['error'][_0x35ac('0x19')]);}logger[_0x35ac('0x17')]('ChatInteraction,\x20%s,\x20%s',_0x1fa3ef,_0x357b71['error'][_0x35ac('0x19')]);return _0x4bb6e8(_0x357b71[_0x35ac('0x17')][_0x35ac('0x19')]);}else{logger[_0x35ac('0x1a')](_0x35ac('0x13'),_0x1fa3ef,_0x35ac('0x14'));_0x4bb6e8(_0x357b71[_0x35ac('0x1b')][_0x35ac('0x19')]);}})[_0x35ac('0x1c')](function(_0x5c4945){logger[_0x35ac('0x17')](_0x35ac('0x13'),_0x1fa3ef,_0x5c4945);_0x281132(_0x5c4945);});});}exports[_0x35ac('0x1d')]=function(_0x4e9ed0){var _0x1c3379=this;return new Promise(function(_0x23e083,_0x42680c){return db['ChatInteraction'][_0x35ac('0x1e')](_0x4e9ed0['body'],{'raw':_0x4e9ed0[_0x35ac('0x1f')]?_0x4e9ed0['options'][_0x35ac('0x20')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x4e9ed0[_0x35ac('0x1f')]?_0x4e9ed0['options']['where']||null:null,'attributes':_0x4e9ed0['options']?_0x4e9ed0['options']['attributes']||null:null,'limit':_0x4e9ed0[_0x35ac('0x1f')]?_0x4e9ed0[_0x35ac('0x1f')][_0x35ac('0x21')]||null:null})[_0x35ac('0x12')](function(_0x2bff13){logger[_0x35ac('0x1a')]('UpdateChatInteraction',_0x4e9ed0);logger['debug'](_0x35ac('0x1d'),_0x4e9ed0,JSON[_0x35ac('0x16')](_0x2bff13));_0x23e083(_0x2bff13);})[_0x35ac('0x1c')](function(_0x3a137d){logger[_0x35ac('0x17')](_0x35ac('0x1d'),_0x3a137d[_0x35ac('0x19')],_0x4e9ed0);_0x42680c(_0x1c3379[_0x35ac('0x17')](0x1f4,_0x3a137d[_0x35ac('0x19')]));});});};exports[_0x35ac('0x22')]=function(_0x50f8f3){return new Promise(function(_0x52a0d0,_0xd80dd1){return db['ChatInteraction'][_0x35ac('0x23')]({'where':_0x50f8f3['options']?_0x50f8f3[_0x35ac('0x1f')][_0x35ac('0x24')]||null:null})['then'](function(_0x33b7b4){if(_0x33b7b4){return _0x33b7b4[_0x35ac('0x25')](_0x50f8f3[_0x35ac('0x26')][_0x35ac('0x27')],_[_0x35ac('0x28')](_0x50f8f3[_0x35ac('0x26')],[_0x35ac('0x27'),'id'])||{});}})['spread'](function(_0x173b75){logger[_0x35ac('0x1a')](_0x35ac('0x29'),_0x50f8f3);logger[_0x35ac('0x2a')](_0x35ac('0x29'),_0x50f8f3,JSON['stringify'](_0x173b75));_0x52a0d0(_0x173b75);})[_0x35ac('0x1c')](function(_0x46767f){logger[_0x35ac('0x17')](_0x35ac('0x29'),_0x46767f[_0x35ac('0x19')],_0x50f8f3);_0xd80dd1(_this[_0x35ac('0x17')](0x1f4,_0x46767f[_0x35ac('0x19')]));});});};