7648fb07dbed44eccb892f457e2c6509f465d567
[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 _0x86bf=['rpc','../../config/environment','jayson/promise','client','http','defaults','localhost','socket.io-emitter','redis','./openchannelInteraction.socket','register','request','then','info','OpenchannelInteraction,\x20%s,\x20%s','request\x20sent','OpenchannelInteraction,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','UpdateOpenchannelInteraction','OpenchannelInteraction','update','body','options','raw','where','debug','catch','AddTagsToOpenchannelInteraction','find','addTags','spread','AddTags','lodash','util','bluebird','randomstring','ioredis','../../config/utils'];(function(_0x9df060,_0x253d33){var _0x338dfe=function(_0x17d9a5){while(--_0x17d9a5){_0x9df060['push'](_0x9df060['shift']());}};_0x338dfe(++_0x253d33);}(_0x86bf,0xa2));var _0xf86b=function(_0x5b2b36,_0x32a693){_0x5b2b36=_0x5b2b36-0x0;var _0x58eef4=_0x86bf[_0x5b2b36];return _0x58eef4;};'use strict';var _=require(_0xf86b('0x0'));var util=require(_0xf86b('0x1'));var moment=require('moment');var BPromise=require(_0xf86b('0x2'));var rs=require(_0xf86b('0x3'));var fs=require('fs');var Redis=require(_0xf86b('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xf86b('0x5'));var logger=require('../../config/logger')(_0xf86b('0x6'));var config=require(_0xf86b('0x7'));var jayson=require(_0xf86b('0x8'));var client=jayson[_0xf86b('0x9')][_0xf86b('0xa')]({'port':0x232a});config['redis']=_[_0xf86b('0xb')](config['redis'],{'host':_0xf86b('0xc'),'port':0x18eb});var socket=require(_0xf86b('0xd'))(new Redis(config[_0xf86b('0xe')]));require(_0xf86b('0xf'))[_0xf86b('0x10')](socket);function respondWithRpcPromise(_0xbdd27f,_0x51d492,_0x407b7f){return new BPromise(function(_0x26c3d8,_0x8e5f52){return client[_0xf86b('0x11')](_0xbdd27f,_0x407b7f)[_0xf86b('0x12')](function(_0xac3415){logger[_0xf86b('0x13')](_0xf86b('0x14'),_0x51d492,_0xf86b('0x15'));logger['debug'](_0xf86b('0x16'),_0x51d492,_0xf86b('0x15'),JSON[_0xf86b('0x17')](_0xac3415));if(_0xac3415[_0xf86b('0x18')]){if(_0xac3415[_0xf86b('0x18')][_0xf86b('0x19')]===0x1f4){logger[_0xf86b('0x18')]('OpenchannelInteraction,\x20%s,\x20%s',_0x51d492,_0xac3415[_0xf86b('0x18')][_0xf86b('0x1a')]);return _0x8e5f52(_0xac3415[_0xf86b('0x18')][_0xf86b('0x1a')]);}logger[_0xf86b('0x18')](_0xf86b('0x14'),_0x51d492,_0xac3415[_0xf86b('0x18')][_0xf86b('0x1a')]);return _0x26c3d8(_0xac3415['error']['message']);}else{logger[_0xf86b('0x13')](_0xf86b('0x14'),_0x51d492,_0xf86b('0x15'));_0x26c3d8(_0xac3415[_0xf86b('0x1b')]['message']);}})['catch'](function(_0xf80e8b){logger['error'](_0xf86b('0x14'),_0x51d492,_0xf80e8b);_0x8e5f52(_0xf80e8b);});});}exports[_0xf86b('0x1c')]=function(_0x112237){var _0x3cedd1=this;return new Promise(function(_0x3aa8a1,_0x4015d2){return db[_0xf86b('0x1d')][_0xf86b('0x1e')](_0x112237[_0xf86b('0x1f')],{'raw':_0x112237[_0xf86b('0x20')]?_0x112237[_0xf86b('0x20')][_0xf86b('0x21')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x112237[_0xf86b('0x20')]?_0x112237[_0xf86b('0x20')][_0xf86b('0x22')]||null:null,'attributes':_0x112237[_0xf86b('0x20')]?_0x112237[_0xf86b('0x20')]['attributes']||null:null,'limit':_0x112237[_0xf86b('0x20')]?_0x112237['options']['limit']||null:null})[_0xf86b('0x12')](function(_0x133af3){logger[_0xf86b('0x13')](_0xf86b('0x1c'),_0x112237);logger[_0xf86b('0x23')]('UpdateOpenchannelInteraction',_0x112237,JSON['stringify'](_0x133af3));_0x3aa8a1(_0x133af3);})[_0xf86b('0x24')](function(_0x450cee){logger[_0xf86b('0x18')]('UpdateOpenchannelInteraction',_0x450cee[_0xf86b('0x1a')],_0x112237);_0x4015d2(_0x3cedd1[_0xf86b('0x18')](0x1f4,_0x450cee[_0xf86b('0x1a')]));});});};exports[_0xf86b('0x25')]=function(_0x48b7a4){return new Promise(function(_0x568697,_0x43bc35){return db[_0xf86b('0x1d')][_0xf86b('0x26')]({'where':_0x48b7a4[_0xf86b('0x20')]?_0x48b7a4[_0xf86b('0x20')]['where']||null:null})[_0xf86b('0x12')](function(_0x322c5e){if(_0x322c5e){return _0x322c5e[_0xf86b('0x27')](_0x48b7a4['body']['ids'],_['omit'](_0x48b7a4[_0xf86b('0x1f')],['ids','id'])||{});}})[_0xf86b('0x28')](function(_0x44b3c0){logger['info'](_0xf86b('0x29'),_0x48b7a4);logger[_0xf86b('0x23')]('AddTags',_0x48b7a4,JSON['stringify'](_0x44b3c0));_0x568697(_0x44b3c0);})[_0xf86b('0x24')](function(_0x5a2faf){logger[_0xf86b('0x18')](_0xf86b('0x29'),_0x5a2faf[_0xf86b('0x1a')],_0x48b7a4);_0x43bc35(_this['error'](0x1f4,_0x5a2faf[_0xf86b('0x1a')]));});});};