1760593e5b15fb76b8e90d0717e7a872920bdc9d
[motion2.git] / server / api / openchannelInteraction / openchannelInteraction.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 _0xbff5=['../../config/logger','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','register','then','info','OpenchannelInteraction,\x20%s,\x20%s','debug','request\x20sent','stringify','error','code','message','result','catch','UpdateOpenchannelInteraction','OpenchannelInteraction','update','body','options','raw','where','attributes','limit','AddTagsToOpenchannelInteraction','addTags','ids','spread','AddTags','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb'];(function(_0x36c6eb,_0x4fb127){var _0x30675b=function(_0x3a788b){while(--_0x3a788b){_0x36c6eb['push'](_0x36c6eb['shift']());}};_0x30675b(++_0x4fb127);}(_0xbff5,0x1bc));var _0x5bff=function(_0x6ecbc7,_0x595c83){_0x6ecbc7=_0x6ecbc7-0x0;var _0x4e9ac7=_0xbff5[_0x6ecbc7];return _0x4e9ac7;};'use strict';var _=require(_0x5bff('0x0'));var util=require(_0x5bff('0x1'));var moment=require(_0x5bff('0x2'));var BPromise=require(_0x5bff('0x3'));var rs=require(_0x5bff('0x4'));var fs=require('fs');var Redis=require(_0x5bff('0x5'));var db=require(_0x5bff('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0x5bff('0x7'))('rpc');var config=require('../../config/environment');var jayson=require(_0x5bff('0x8'));var client=jayson[_0x5bff('0x9')][_0x5bff('0xa')]({'port':0x232a});config[_0x5bff('0xb')]=_[_0x5bff('0xc')](config[_0x5bff('0xb')],{'host':_0x5bff('0xd'),'port':0x18eb});var socket=require(_0x5bff('0xe'))(new Redis(config[_0x5bff('0xb')]));require('./openchannelInteraction.socket')[_0x5bff('0xf')](socket);function respondWithRpcPromise(_0x5e7d10,_0x1d8197,_0x40b806){return new BPromise(function(_0x4fc146,_0x3e72e9){return client['request'](_0x5e7d10,_0x40b806)[_0x5bff('0x10')](function(_0x4ff164){logger[_0x5bff('0x11')](_0x5bff('0x12'),_0x1d8197,'request\x20sent');logger[_0x5bff('0x13')]('OpenchannelInteraction,\x20%s,\x20%s,\x20%s',_0x1d8197,_0x5bff('0x14'),JSON[_0x5bff('0x15')](_0x4ff164));if(_0x4ff164['error']){if(_0x4ff164[_0x5bff('0x16')][_0x5bff('0x17')]===0x1f4){logger['error']('OpenchannelInteraction,\x20%s,\x20%s',_0x1d8197,_0x4ff164[_0x5bff('0x16')][_0x5bff('0x18')]);return _0x3e72e9(_0x4ff164[_0x5bff('0x16')]['message']);}logger[_0x5bff('0x16')](_0x5bff('0x12'),_0x1d8197,_0x4ff164[_0x5bff('0x16')]['message']);return _0x4fc146(_0x4ff164[_0x5bff('0x16')][_0x5bff('0x18')]);}else{logger[_0x5bff('0x11')]('OpenchannelInteraction,\x20%s,\x20%s',_0x1d8197,_0x5bff('0x14'));_0x4fc146(_0x4ff164[_0x5bff('0x19')][_0x5bff('0x18')]);}})[_0x5bff('0x1a')](function(_0x5216dc){logger[_0x5bff('0x16')]('OpenchannelInteraction,\x20%s,\x20%s',_0x1d8197,_0x5216dc);_0x3e72e9(_0x5216dc);});});}exports[_0x5bff('0x1b')]=function(_0x4d0111){var _0x1fc4cf=this;return new Promise(function(_0x13d5d0,_0x2a83ce){return db[_0x5bff('0x1c')][_0x5bff('0x1d')](_0x4d0111[_0x5bff('0x1e')],{'raw':_0x4d0111[_0x5bff('0x1f')]?_0x4d0111[_0x5bff('0x1f')][_0x5bff('0x20')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x4d0111['options']?_0x4d0111[_0x5bff('0x1f')][_0x5bff('0x21')]||null:null,'attributes':_0x4d0111[_0x5bff('0x1f')]?_0x4d0111[_0x5bff('0x1f')][_0x5bff('0x22')]||null:null,'limit':_0x4d0111[_0x5bff('0x1f')]?_0x4d0111[_0x5bff('0x1f')][_0x5bff('0x23')]||null:null})['then'](function(_0x5741d9){logger[_0x5bff('0x11')]('UpdateOpenchannelInteraction',_0x4d0111);logger[_0x5bff('0x13')](_0x5bff('0x1b'),_0x4d0111,JSON[_0x5bff('0x15')](_0x5741d9));_0x13d5d0(_0x5741d9);})[_0x5bff('0x1a')](function(_0xfa361d){logger[_0x5bff('0x16')](_0x5bff('0x1b'),_0xfa361d[_0x5bff('0x18')],_0x4d0111);_0x2a83ce(_0x1fc4cf['error'](0x1f4,_0xfa361d['message']));});});};exports[_0x5bff('0x24')]=function(_0x2dd52f){return new Promise(function(_0x4d7640,_0x36a7d2){return db['OpenchannelInteraction']['find']({'where':_0x2dd52f[_0x5bff('0x1f')]?_0x2dd52f['options'][_0x5bff('0x21')]||null:null})[_0x5bff('0x10')](function(_0x2d692a){if(_0x2d692a){return _0x2d692a[_0x5bff('0x25')](_0x2dd52f['body'][_0x5bff('0x26')],_['omit'](_0x2dd52f[_0x5bff('0x1e')],['ids','id'])||{});}})[_0x5bff('0x27')](function(_0x100d0c){logger[_0x5bff('0x11')](_0x5bff('0x28'),_0x2dd52f);logger[_0x5bff('0x13')](_0x5bff('0x28'),_0x2dd52f,JSON['stringify'](_0x100d0c));_0x4d7640(_0x100d0c);})[_0x5bff('0x1a')](function(_0x31c33f){logger[_0x5bff('0x16')](_0x5bff('0x28'),_0x31c33f[_0x5bff('0x18')],_0x2dd52f);_0x36a7d2(_this[_0x5bff('0x16')](0x1f4,_0x31c33f[_0x5bff('0x18')]));});});};