Built motion from commit 97153652.|2.6.26
[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 _0x44d8=['../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','localhost','socket.io-emitter','./openchannelInteraction.socket','register','request','then','info','OpenchannelInteraction,\x20%s,\x20%s','debug','OpenchannelInteraction,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','message','result','catch','UpdateOpenchannelInteraction','options','raw','attributes','limit','AddTagsToOpenchannelInteraction','OpenchannelInteraction','find','addTags','body','ids','omit','AddTags','lodash','util','moment','bluebird','ioredis'];(function(_0x524c4f,_0x2d1842){var _0x4656cb=function(_0xef5a42){while(--_0xef5a42){_0x524c4f['push'](_0x524c4f['shift']());}};_0x4656cb(++_0x2d1842);}(_0x44d8,0x1d4));var _0x844d=function(_0x4bbab0,_0xdfbcc9){_0x4bbab0=_0x4bbab0-0x0;var _0x2e9560=_0x44d8[_0x4bbab0];return _0x2e9560;};'use strict';var _=require(_0x844d('0x0'));var util=require(_0x844d('0x1'));var moment=require(_0x844d('0x2'));var BPromise=require(_0x844d('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x844d('0x4'));var db=require(_0x844d('0x5'))['db'];var utils=require(_0x844d('0x6'));var logger=require(_0x844d('0x7'))(_0x844d('0x8'));var config=require(_0x844d('0x9'));var jayson=require(_0x844d('0xa'));var client=jayson[_0x844d('0xb')][_0x844d('0xc')]({'port':0x232a});config[_0x844d('0xd')]=_['defaults'](config[_0x844d('0xd')],{'host':_0x844d('0xe'),'port':0x18eb});var socket=require(_0x844d('0xf'))(new Redis(config[_0x844d('0xd')]));require(_0x844d('0x10'))[_0x844d('0x11')](socket);function respondWithRpcPromise(_0x4a4f15,_0x20055d,_0x3408cf){return new BPromise(function(_0x44e829,_0x305a24){return client[_0x844d('0x12')](_0x4a4f15,_0x3408cf)[_0x844d('0x13')](function(_0x2af4a8){logger[_0x844d('0x14')](_0x844d('0x15'),_0x20055d,'request\x20sent');logger[_0x844d('0x16')](_0x844d('0x17'),_0x20055d,_0x844d('0x18'),JSON[_0x844d('0x19')](_0x2af4a8));if(_0x2af4a8[_0x844d('0x1a')]){if(_0x2af4a8['error']['code']===0x1f4){logger[_0x844d('0x1a')](_0x844d('0x15'),_0x20055d,_0x2af4a8[_0x844d('0x1a')][_0x844d('0x1b')]);return _0x305a24(_0x2af4a8[_0x844d('0x1a')][_0x844d('0x1b')]);}logger['error'](_0x844d('0x15'),_0x20055d,_0x2af4a8[_0x844d('0x1a')][_0x844d('0x1b')]);return _0x44e829(_0x2af4a8[_0x844d('0x1a')]['message']);}else{logger['info'](_0x844d('0x15'),_0x20055d,_0x844d('0x18'));_0x44e829(_0x2af4a8[_0x844d('0x1c')]['message']);}})[_0x844d('0x1d')](function(_0x85cc8a){logger[_0x844d('0x1a')](_0x844d('0x15'),_0x20055d,_0x85cc8a);_0x305a24(_0x85cc8a);});});}exports[_0x844d('0x1e')]=function(_0x43e40c){var _0x205030=this;return new Promise(function(_0x2c4307,_0x4320c1){return db['OpenchannelInteraction']['update'](_0x43e40c['body'],{'raw':_0x43e40c['options']?_0x43e40c[_0x844d('0x1f')][_0x844d('0x20')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x43e40c['options']?_0x43e40c[_0x844d('0x1f')]['where']||null:null,'attributes':_0x43e40c[_0x844d('0x1f')]?_0x43e40c[_0x844d('0x1f')][_0x844d('0x21')]||null:null,'limit':_0x43e40c[_0x844d('0x1f')]?_0x43e40c[_0x844d('0x1f')][_0x844d('0x22')]||null:null})[_0x844d('0x13')](function(_0x4d15a3){logger['info'](_0x844d('0x1e'),_0x43e40c);logger[_0x844d('0x16')](_0x844d('0x1e'),_0x43e40c,JSON[_0x844d('0x19')](_0x4d15a3));_0x2c4307(_0x4d15a3);})[_0x844d('0x1d')](function(_0x4eb3d8){logger['error'](_0x844d('0x1e'),_0x4eb3d8[_0x844d('0x1b')],_0x43e40c);_0x4320c1(_0x205030['error'](0x1f4,_0x4eb3d8[_0x844d('0x1b')]));});});};exports[_0x844d('0x23')]=function(_0x90a871){return new Promise(function(_0x10e972,_0x1d3ced){return db[_0x844d('0x24')][_0x844d('0x25')]({'where':_0x90a871[_0x844d('0x1f')]?_0x90a871['options']['where']||null:null})['then'](function(_0x56aead){if(_0x56aead){return _0x56aead[_0x844d('0x26')](_0x90a871[_0x844d('0x27')][_0x844d('0x28')],_[_0x844d('0x29')](_0x90a871[_0x844d('0x27')],[_0x844d('0x28'),'id'])||{});}})['spread'](function(_0x303166){logger['info'](_0x844d('0x2a'),_0x90a871);logger['debug']('AddTags',_0x90a871,JSON[_0x844d('0x19')](_0x303166));_0x10e972(_0x303166);})[_0x844d('0x1d')](function(_0xc8795b){logger[_0x844d('0x1a')](_0x844d('0x2a'),_0xc8795b['message'],_0x90a871);_0x1d3ced(_this[_0x844d('0x1a')](0x1f4,_0xc8795b[_0x844d('0x1b')]));});});};