614445f9746f5c8861b91eb50d9cc5ebac1c0927
[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 _0xf577=['socket.io-emitter','register','request','then','OpenchannelInteraction,\x20%s,\x20%s','request\x20sent','error','code','message','info','result','catch','OpenchannelInteraction','update','body','options','raw','where','limit','UpdateOpenchannelInteraction','debug','stringify','AddTagsToOpenchannelInteraction','find','addTags','ids','omit','AddTags','lodash','moment','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','defaults','redis','localhost'];(function(_0x2dafbe,_0x5d04de){var _0x58a45a=function(_0x50ac96){while(--_0x50ac96){_0x2dafbe['push'](_0x2dafbe['shift']());}};_0x58a45a(++_0x5d04de);}(_0xf577,0x142));var _0x7f57=function(_0x39096d,_0x51f8a0){_0x39096d=_0x39096d-0x0;var _0x13da4f=_0xf577[_0x39096d];return _0x13da4f;};'use strict';var _=require(_0x7f57('0x0'));var util=require('util');var moment=require(_0x7f57('0x1'));var BPromise=require('bluebird');var rs=require(_0x7f57('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x7f57('0x3'))['db'];var utils=require(_0x7f57('0x4'));var logger=require(_0x7f57('0x5'))(_0x7f57('0x6'));var config=require(_0x7f57('0x7'));var jayson=require(_0x7f57('0x8'));var client=jayson[_0x7f57('0x9')][_0x7f57('0xa')]({'port':0x232a});config['redis']=_[_0x7f57('0xb')](config[_0x7f57('0xc')],{'host':_0x7f57('0xd'),'port':0x18eb});var socket=require(_0x7f57('0xe'))(new Redis(config[_0x7f57('0xc')]));require('./openchannelInteraction.socket')[_0x7f57('0xf')](socket);function respondWithRpcPromise(_0x2a5cf2,_0x3379d7,_0x146643){return new BPromise(function(_0x46efe7,_0x170170){return client[_0x7f57('0x10')](_0x2a5cf2,_0x146643)[_0x7f57('0x11')](function(_0x1e6e2f){logger['info'](_0x7f57('0x12'),_0x3379d7,_0x7f57('0x13'));logger['debug']('OpenchannelInteraction,\x20%s,\x20%s,\x20%s',_0x3379d7,'request\x20sent',JSON['stringify'](_0x1e6e2f));if(_0x1e6e2f['error']){if(_0x1e6e2f[_0x7f57('0x14')][_0x7f57('0x15')]===0x1f4){logger[_0x7f57('0x14')](_0x7f57('0x12'),_0x3379d7,_0x1e6e2f[_0x7f57('0x14')][_0x7f57('0x16')]);return _0x170170(_0x1e6e2f[_0x7f57('0x14')]['message']);}logger[_0x7f57('0x14')](_0x7f57('0x12'),_0x3379d7,_0x1e6e2f['error'][_0x7f57('0x16')]);return _0x46efe7(_0x1e6e2f[_0x7f57('0x14')]['message']);}else{logger[_0x7f57('0x17')]('OpenchannelInteraction,\x20%s,\x20%s',_0x3379d7,_0x7f57('0x13'));_0x46efe7(_0x1e6e2f[_0x7f57('0x18')]['message']);}})[_0x7f57('0x19')](function(_0x168847){logger[_0x7f57('0x14')](_0x7f57('0x12'),_0x3379d7,_0x168847);_0x170170(_0x168847);});});}exports['UpdateOpenchannelInteraction']=function(_0x51e594){var _0x42d3ff=this;return new Promise(function(_0x2957e7,_0x95a1e2){return db[_0x7f57('0x1a')][_0x7f57('0x1b')](_0x51e594[_0x7f57('0x1c')],{'raw':_0x51e594['options']?_0x51e594[_0x7f57('0x1d')][_0x7f57('0x1e')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x51e594[_0x7f57('0x1d')]?_0x51e594['options'][_0x7f57('0x1f')]||null:null,'attributes':_0x51e594[_0x7f57('0x1d')]?_0x51e594[_0x7f57('0x1d')]['attributes']||null:null,'limit':_0x51e594[_0x7f57('0x1d')]?_0x51e594[_0x7f57('0x1d')][_0x7f57('0x20')]||null:null})[_0x7f57('0x11')](function(_0x37ff1b){logger[_0x7f57('0x17')](_0x7f57('0x21'),_0x51e594);logger[_0x7f57('0x22')](_0x7f57('0x21'),_0x51e594,JSON[_0x7f57('0x23')](_0x37ff1b));_0x2957e7(_0x37ff1b);})[_0x7f57('0x19')](function(_0x16376b){logger[_0x7f57('0x14')](_0x7f57('0x21'),_0x16376b['message'],_0x51e594);_0x95a1e2(_0x42d3ff[_0x7f57('0x14')](0x1f4,_0x16376b[_0x7f57('0x16')]));});});};exports[_0x7f57('0x24')]=function(_0x2bf2b0){return new Promise(function(_0x41cffc,_0x2d57a8){return db[_0x7f57('0x1a')][_0x7f57('0x25')]({'where':_0x2bf2b0[_0x7f57('0x1d')]?_0x2bf2b0[_0x7f57('0x1d')][_0x7f57('0x1f')]||null:null})[_0x7f57('0x11')](function(_0xa73712){if(_0xa73712){return _0xa73712[_0x7f57('0x26')](_0x2bf2b0[_0x7f57('0x1c')][_0x7f57('0x27')],_[_0x7f57('0x28')](_0x2bf2b0['body'],['ids','id'])||{});}})['spread'](function(_0x20502f){logger[_0x7f57('0x17')]('AddTags',_0x2bf2b0);logger[_0x7f57('0x22')](_0x7f57('0x29'),_0x2bf2b0,JSON[_0x7f57('0x23')](_0x20502f));_0x41cffc(_0x20502f);})[_0x7f57('0x19')](function(_0xc107ac){logger[_0x7f57('0x14')](_0x7f57('0x29'),_0xc107ac[_0x7f57('0x16')],_0x2bf2b0);_0x2d57a8(_this[_0x7f57('0x14')](0x1f4,_0xc107ac[_0x7f57('0x16')]));});});};