09603ff8615a8a34dc20ad339e9fdd9bb8181edc
[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 _0x59db=['addTags','omit','ids','spread','AddTags','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','client','http','redis','defaults','localhost','socket.io-emitter','./openchannelInteraction.socket','register','request','then','info','OpenchannelInteraction,\x20%s,\x20%s','debug','OpenchannelInteraction,\x20%s,\x20%s,\x20%s','stringify','code','error','message','request\x20sent','result','catch','UpdateOpenchannelInteraction','OpenchannelInteraction','update','body','options','where','attributes','limit','AddTagsToOpenchannelInteraction'];(function(_0x502c7d,_0x2f1285){var _0x30b7ed=function(_0x2d92f3){while(--_0x2d92f3){_0x502c7d['push'](_0x502c7d['shift']());}};_0x30b7ed(++_0x2f1285);}(_0x59db,0xb5));var _0xb59d=function(_0x105d7b,_0x2051a3){_0x105d7b=_0x105d7b-0x0;var _0x45d235=_0x59db[_0x105d7b];return _0x45d235;};'use strict';var _=require(_0xb59d('0x0'));var util=require('util');var moment=require(_0xb59d('0x1'));var BPromise=require(_0xb59d('0x2'));var rs=require(_0xb59d('0x3'));var fs=require('fs');var Redis=require(_0xb59d('0x4'));var db=require(_0xb59d('0x5'))['db'];var utils=require(_0xb59d('0x6'));var logger=require(_0xb59d('0x7'))('rpc');var config=require(_0xb59d('0x8'));var jayson=require('jayson/promise');var client=jayson[_0xb59d('0x9')][_0xb59d('0xa')]({'port':0x232a});config[_0xb59d('0xb')]=_[_0xb59d('0xc')](config[_0xb59d('0xb')],{'host':_0xb59d('0xd'),'port':0x18eb});var socket=require(_0xb59d('0xe'))(new Redis(config[_0xb59d('0xb')]));require(_0xb59d('0xf'))[_0xb59d('0x10')](socket);function respondWithRpcPromise(_0x3b56e3,_0x234167,_0x42a088){return new BPromise(function(_0x32a190,_0x495346){return client[_0xb59d('0x11')](_0x3b56e3,_0x42a088)[_0xb59d('0x12')](function(_0x440e92){logger[_0xb59d('0x13')](_0xb59d('0x14'),_0x234167,'request\x20sent');logger[_0xb59d('0x15')](_0xb59d('0x16'),_0x234167,'request\x20sent',JSON[_0xb59d('0x17')](_0x440e92));if(_0x440e92['error']){if(_0x440e92['error'][_0xb59d('0x18')]===0x1f4){logger[_0xb59d('0x19')](_0xb59d('0x14'),_0x234167,_0x440e92[_0xb59d('0x19')]['message']);return _0x495346(_0x440e92[_0xb59d('0x19')][_0xb59d('0x1a')]);}logger[_0xb59d('0x19')](_0xb59d('0x14'),_0x234167,_0x440e92[_0xb59d('0x19')][_0xb59d('0x1a')]);return _0x32a190(_0x440e92[_0xb59d('0x19')]['message']);}else{logger[_0xb59d('0x13')]('OpenchannelInteraction,\x20%s,\x20%s',_0x234167,_0xb59d('0x1b'));_0x32a190(_0x440e92[_0xb59d('0x1c')]['message']);}})[_0xb59d('0x1d')](function(_0x10b30b){logger[_0xb59d('0x19')]('OpenchannelInteraction,\x20%s,\x20%s',_0x234167,_0x10b30b);_0x495346(_0x10b30b);});});}exports[_0xb59d('0x1e')]=function(_0x53e00d){var _0x2736cf=this;return new Promise(function(_0x1acfde,_0x59af3e){return db[_0xb59d('0x1f')][_0xb59d('0x20')](_0x53e00d[_0xb59d('0x21')],{'raw':_0x53e00d[_0xb59d('0x22')]?_0x53e00d[_0xb59d('0x22')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x53e00d[_0xb59d('0x22')]?_0x53e00d[_0xb59d('0x22')][_0xb59d('0x23')]||null:null,'attributes':_0x53e00d['options']?_0x53e00d[_0xb59d('0x22')][_0xb59d('0x24')]||null:null,'limit':_0x53e00d[_0xb59d('0x22')]?_0x53e00d[_0xb59d('0x22')][_0xb59d('0x25')]||null:null})['then'](function(_0x524b8e){logger['info'](_0xb59d('0x1e'),_0x53e00d);logger['debug'](_0xb59d('0x1e'),_0x53e00d,JSON[_0xb59d('0x17')](_0x524b8e));_0x1acfde(_0x524b8e);})['catch'](function(_0x1c8887){logger['error'](_0xb59d('0x1e'),_0x1c8887['message'],_0x53e00d);_0x59af3e(_0x2736cf['error'](0x1f4,_0x1c8887['message']));});});};exports[_0xb59d('0x26')]=function(_0x21076d){return new Promise(function(_0x4ec944,_0x4b3ad9){return db['OpenchannelInteraction']['find']({'where':_0x21076d['options']?_0x21076d['options'][_0xb59d('0x23')]||null:null})[_0xb59d('0x12')](function(_0x503a49){if(_0x503a49){return _0x503a49[_0xb59d('0x27')](_0x21076d['body']['ids'],_[_0xb59d('0x28')](_0x21076d[_0xb59d('0x21')],[_0xb59d('0x29'),'id'])||{});}})[_0xb59d('0x2a')](function(_0xf1258d){logger['info'](_0xb59d('0x2b'),_0x21076d);logger[_0xb59d('0x15')](_0xb59d('0x2b'),_0x21076d,JSON[_0xb59d('0x17')](_0xf1258d));_0x4ec944(_0xf1258d);})['catch'](function(_0x2c5a42){logger[_0xb59d('0x19')](_0xb59d('0x2b'),_0x2c5a42[_0xb59d('0x1a')],_0x21076d);_0x4b3ad9(_this[_0xb59d('0x19')](0x1f4,_0x2c5a42[_0xb59d('0x1a')]));});});};