147b4a0f61dc88317ffa9bb5f780f583becac040
[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 _0xa4cb=['stringify','error','code','message','catch','UpdateOpenchannelInteraction','OpenchannelInteraction','body','options','raw','where','debug','AddTagsToOpenchannelInteraction','find','addTags','omit','ids','spread','AddTags','util','moment','bluebird','randomstring','../../mysqldb','../../config/logger','rpc','../../config/environment','client','http','redis','defaults','socket.io-emitter','register','request','then','info','OpenchannelInteraction,\x20%s,\x20%s','request\x20sent','OpenchannelInteraction,\x20%s,\x20%s,\x20%s'];(function(_0x1abb9f,_0x4ad1d7){var _0x3b52be=function(_0x28f503){while(--_0x28f503){_0x1abb9f['push'](_0x1abb9f['shift']());}};_0x3b52be(++_0x4ad1d7);}(_0xa4cb,0x88));var _0xba4c=function(_0x8f8669,_0x41a6fb){_0x8f8669=_0x8f8669-0x0;var _0x59f91a=_0xa4cb[_0x8f8669];return _0x59f91a;};'use strict';var _=require('lodash');var util=require(_0xba4c('0x0'));var moment=require(_0xba4c('0x1'));var BPromise=require(_0xba4c('0x2'));var rs=require(_0xba4c('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xba4c('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0xba4c('0x5'))(_0xba4c('0x6'));var config=require(_0xba4c('0x7'));var jayson=require('jayson/promise');var client=jayson[_0xba4c('0x8')][_0xba4c('0x9')]({'port':0x232a});config[_0xba4c('0xa')]=_[_0xba4c('0xb')](config[_0xba4c('0xa')],{'host':'localhost','port':0x18eb});var socket=require(_0xba4c('0xc'))(new Redis(config['redis']));require('./openchannelInteraction.socket')[_0xba4c('0xd')](socket);function respondWithRpcPromise(_0x1c2242,_0x16212c,_0x9f1ad1){return new BPromise(function(_0x15bd8c,_0x1daa32){return client[_0xba4c('0xe')](_0x1c2242,_0x9f1ad1)[_0xba4c('0xf')](function(_0x5c6e23){logger[_0xba4c('0x10')](_0xba4c('0x11'),_0x16212c,_0xba4c('0x12'));logger['debug'](_0xba4c('0x13'),_0x16212c,_0xba4c('0x12'),JSON[_0xba4c('0x14')](_0x5c6e23));if(_0x5c6e23[_0xba4c('0x15')]){if(_0x5c6e23[_0xba4c('0x15')][_0xba4c('0x16')]===0x1f4){logger['error']('OpenchannelInteraction,\x20%s,\x20%s',_0x16212c,_0x5c6e23[_0xba4c('0x15')]['message']);return _0x1daa32(_0x5c6e23['error']['message']);}logger[_0xba4c('0x15')]('OpenchannelInteraction,\x20%s,\x20%s',_0x16212c,_0x5c6e23[_0xba4c('0x15')][_0xba4c('0x17')]);return _0x15bd8c(_0x5c6e23[_0xba4c('0x15')][_0xba4c('0x17')]);}else{logger['info'](_0xba4c('0x11'),_0x16212c,_0xba4c('0x12'));_0x15bd8c(_0x5c6e23['result'][_0xba4c('0x17')]);}})[_0xba4c('0x18')](function(_0xfaf78){logger[_0xba4c('0x15')](_0xba4c('0x11'),_0x16212c,_0xfaf78);_0x1daa32(_0xfaf78);});});}exports[_0xba4c('0x19')]=function(_0x20aa43){var _0x3dad95=this;return new Promise(function(_0x31a38b,_0x52deca){return db[_0xba4c('0x1a')]['update'](_0x20aa43[_0xba4c('0x1b')],{'raw':_0x20aa43[_0xba4c('0x1c')]?_0x20aa43['options'][_0xba4c('0x1d')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x20aa43[_0xba4c('0x1c')]?_0x20aa43[_0xba4c('0x1c')][_0xba4c('0x1e')]||null:null,'attributes':_0x20aa43[_0xba4c('0x1c')]?_0x20aa43[_0xba4c('0x1c')]['attributes']||null:null,'limit':_0x20aa43['options']?_0x20aa43[_0xba4c('0x1c')]['limit']||null:null})[_0xba4c('0xf')](function(_0x1797fc){logger[_0xba4c('0x10')]('UpdateOpenchannelInteraction',_0x20aa43);logger[_0xba4c('0x1f')](_0xba4c('0x19'),_0x20aa43,JSON[_0xba4c('0x14')](_0x1797fc));_0x31a38b(_0x1797fc);})[_0xba4c('0x18')](function(_0x3c59b0){logger[_0xba4c('0x15')](_0xba4c('0x19'),_0x3c59b0[_0xba4c('0x17')],_0x20aa43);_0x52deca(_0x3dad95[_0xba4c('0x15')](0x1f4,_0x3c59b0['message']));});});};exports[_0xba4c('0x20')]=function(_0x56e78a){return new Promise(function(_0x67b514,_0x4ab1c2){return db[_0xba4c('0x1a')][_0xba4c('0x21')]({'where':_0x56e78a[_0xba4c('0x1c')]?_0x56e78a[_0xba4c('0x1c')][_0xba4c('0x1e')]||null:null})[_0xba4c('0xf')](function(_0x4fb2bf){if(_0x4fb2bf){return _0x4fb2bf[_0xba4c('0x22')](_0x56e78a[_0xba4c('0x1b')]['ids'],_[_0xba4c('0x23')](_0x56e78a[_0xba4c('0x1b')],[_0xba4c('0x24'),'id'])||{});}})[_0xba4c('0x25')](function(_0x5ea40a){logger[_0xba4c('0x10')](_0xba4c('0x26'),_0x56e78a);logger['debug'](_0xba4c('0x26'),_0x56e78a,JSON[_0xba4c('0x14')](_0x5ea40a));_0x67b514(_0x5ea40a);})[_0xba4c('0x18')](function(_0x3f2f39){logger['error'](_0xba4c('0x26'),_0x3f2f39[_0xba4c('0x17')],_0x56e78a);_0x4ab1c2(_this['error'](0x1f4,_0x3f2f39['message']));});});};