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 _0x2963=['socket.io-emitter','./chatInteraction.socket','register','request','then','info','ChatInteraction,\x20%s,\x20%s','request\x20sent','debug','ChatInteraction,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','UpdateChatInteraction','ChatInteraction','update','body','options','raw','where','attributes','AddTagsToChatInteraction','find','addTags','ids','spread','AddTags','stringify','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/environment','jayson/promise','client','http','defaults','redis'];(function(_0x3358ba,_0x24c5fc){var _0x296e73=function(_0x843ff3){while(--_0x843ff3){_0x3358ba['push'](_0x3358ba['shift']());}};_0x296e73(++_0x24c5fc);}(_0x2963,0x72));var _0x3296=function(_0x15970d,_0x4f2c51){_0x15970d=_0x15970d-0x0;var _0x5244d0=_0x2963[_0x15970d];return _0x5244d0;};'use strict';var _=require(_0x3296('0x0'));var util=require(_0x3296('0x1'));var moment=require(_0x3296('0x2'));var BPromise=require('bluebird');var rs=require(_0x3296('0x3'));var fs=require('fs');var Redis=require(_0x3296('0x4'));var db=require(_0x3296('0x5'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')('rpc');var config=require(_0x3296('0x6'));var jayson=require(_0x3296('0x7'));var client=jayson[_0x3296('0x8')][_0x3296('0x9')]({'port':0x232a});config['redis']=_[_0x3296('0xa')](config[_0x3296('0xb')],{'host':'localhost','port':0x18eb});var socket=require(_0x3296('0xc'))(new Redis(config[_0x3296('0xb')]));require(_0x3296('0xd'))[_0x3296('0xe')](socket);function respondWithRpcPromise(_0x9a0748,_0x3533af,_0x367f93){return new BPromise(function(_0x273fa2,_0x145fde){return client[_0x3296('0xf')](_0x9a0748,_0x367f93)[_0x3296('0x10')](function(_0x21626e){logger[_0x3296('0x11')](_0x3296('0x12'),_0x3533af,_0x3296('0x13'));logger[_0x3296('0x14')](_0x3296('0x15'),_0x3533af,_0x3296('0x13'),JSON['stringify'](_0x21626e));if(_0x21626e[_0x3296('0x16')]){if(_0x21626e['error'][_0x3296('0x17')]===0x1f4){logger[_0x3296('0x16')](_0x3296('0x12'),_0x3533af,_0x21626e['error']['message']);return _0x145fde(_0x21626e['error'][_0x3296('0x18')]);}logger[_0x3296('0x16')](_0x3296('0x12'),_0x3533af,_0x21626e[_0x3296('0x16')]['message']);return _0x273fa2(_0x21626e[_0x3296('0x16')][_0x3296('0x18')]);}else{logger['info']('ChatInteraction,\x20%s,\x20%s',_0x3533af,_0x3296('0x13'));_0x273fa2(_0x21626e[_0x3296('0x19')][_0x3296('0x18')]);}})[_0x3296('0x1a')](function(_0xf99696){logger[_0x3296('0x16')](_0x3296('0x12'),_0x3533af,_0xf99696);_0x145fde(_0xf99696);});});}exports[_0x3296('0x1b')]=function(_0x191dc9){var _0x5c9975=this;return new Promise(function(_0x1913ac,_0x6d47a6){return db[_0x3296('0x1c')][_0x3296('0x1d')](_0x191dc9[_0x3296('0x1e')],{'raw':_0x191dc9['options']?_0x191dc9[_0x3296('0x1f')][_0x3296('0x20')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x191dc9[_0x3296('0x1f')]?_0x191dc9[_0x3296('0x1f')][_0x3296('0x21')]||null:null,'attributes':_0x191dc9['options']?_0x191dc9['options'][_0x3296('0x22')]||null:null,'limit':_0x191dc9[_0x3296('0x1f')]?_0x191dc9[_0x3296('0x1f')]['limit']||null:null})['then'](function(_0x271c99){logger[_0x3296('0x11')](_0x3296('0x1b'),_0x191dc9);logger['debug']('UpdateChatInteraction',_0x191dc9,JSON['stringify'](_0x271c99));_0x1913ac(_0x271c99);})[_0x3296('0x1a')](function(_0x469767){logger[_0x3296('0x16')](_0x3296('0x1b'),_0x469767[_0x3296('0x18')],_0x191dc9);_0x6d47a6(_0x5c9975[_0x3296('0x16')](0x1f4,_0x469767['message']));});});};exports[_0x3296('0x23')]=function(_0x47adef){return new Promise(function(_0x12f158,_0x37fb2d){return db[_0x3296('0x1c')][_0x3296('0x24')]({'where':_0x47adef[_0x3296('0x1f')]?_0x47adef[_0x3296('0x1f')]['where']||null:null})[_0x3296('0x10')](function(_0x212ccf){if(_0x212ccf){return _0x212ccf[_0x3296('0x25')](_0x47adef['body']['ids'],_['omit'](_0x47adef[_0x3296('0x1e')],[_0x3296('0x26'),'id'])||{});}})[_0x3296('0x27')](function(_0x3496c2){logger[_0x3296('0x11')](_0x3296('0x28'),_0x47adef);logger[_0x3296('0x14')]('AddTags',_0x47adef,JSON[_0x3296('0x29')](_0x3496c2));_0x12f158(_0x3496c2);})['catch'](function(_0x16f09){logger[_0x3296('0x16')](_0x3296('0x28'),_0x16f09['message'],_0x47adef);_0x37fb2d(_this[_0x3296('0x16')](0x1f4,_0x16f09[_0x3296('0x18')]));});});};