5a85d0f7756f41f458c8501335f94853497b4a10
[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 _0xbb17=['OpenchannelInteraction','where','addTags','ids','omit','spread','AddTags','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','rpc','jayson/promise','client','redis','defaults','localhost','socket.io-emitter','./openchannelInteraction.socket','register','request','then','info','OpenchannelInteraction,\x20%s,\x20%s,\x20%s','error','OpenchannelInteraction,\x20%s,\x20%s','message','UpdateOpenchannelInteraction','update','body','options','raw','attributes','limit','debug','catch','AddTagsToOpenchannelInteraction'];(function(_0x24c745,_0x469776){var _0xd6b650=function(_0x822c07){while(--_0x822c07){_0x24c745['push'](_0x24c745['shift']());}};_0xd6b650(++_0x469776);}(_0xbb17,0x1bf));var _0x7bb1=function(_0x2c91e9,_0x2fb965){_0x2c91e9=_0x2c91e9-0x0;var _0x13f0ff=_0xbb17[_0x2c91e9];return _0x13f0ff;};'use strict';var _=require(_0x7bb1('0x0'));var util=require(_0x7bb1('0x1'));var moment=require(_0x7bb1('0x2'));var BPromise=require(_0x7bb1('0x3'));var rs=require(_0x7bb1('0x4'));var fs=require('fs');var Redis=require(_0x7bb1('0x5'));var db=require(_0x7bb1('0x6'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x7bb1('0x7'));var config=require('../../config/environment');var jayson=require(_0x7bb1('0x8'));var client=jayson[_0x7bb1('0x9')]['http']({'port':0x232a});config[_0x7bb1('0xa')]=_[_0x7bb1('0xb')](config[_0x7bb1('0xa')],{'host':_0x7bb1('0xc'),'port':0x18eb});var socket=require(_0x7bb1('0xd'))(new Redis(config['redis']));require(_0x7bb1('0xe'))[_0x7bb1('0xf')](socket);function respondWithRpcPromise(_0x8dd032,_0x2e3d46,_0x59f74f){return new BPromise(function(_0x395fbe,_0x562ac9){return client[_0x7bb1('0x10')](_0x8dd032,_0x59f74f)[_0x7bb1('0x11')](function(_0x5c1eef){logger[_0x7bb1('0x12')]('OpenchannelInteraction,\x20%s,\x20%s',_0x2e3d46,'request\x20sent');logger['debug'](_0x7bb1('0x13'),_0x2e3d46,'request\x20sent',JSON['stringify'](_0x5c1eef));if(_0x5c1eef['error']){if(_0x5c1eef[_0x7bb1('0x14')]['code']===0x1f4){logger[_0x7bb1('0x14')](_0x7bb1('0x15'),_0x2e3d46,_0x5c1eef['error'][_0x7bb1('0x16')]);return _0x562ac9(_0x5c1eef['error'][_0x7bb1('0x16')]);}logger[_0x7bb1('0x14')](_0x7bb1('0x15'),_0x2e3d46,_0x5c1eef['error']['message']);return _0x395fbe(_0x5c1eef[_0x7bb1('0x14')]['message']);}else{logger['info'](_0x7bb1('0x15'),_0x2e3d46,'request\x20sent');_0x395fbe(_0x5c1eef['result'][_0x7bb1('0x16')]);}})['catch'](function(_0x6e3a62){logger[_0x7bb1('0x14')](_0x7bb1('0x15'),_0x2e3d46,_0x6e3a62);_0x562ac9(_0x6e3a62);});});}exports[_0x7bb1('0x17')]=function(_0x5cf6b2){var _0x253593=this;return new Promise(function(_0x1fb05c,_0x3360f3){return db['OpenchannelInteraction'][_0x7bb1('0x18')](_0x5cf6b2[_0x7bb1('0x19')],{'raw':_0x5cf6b2[_0x7bb1('0x1a')]?_0x5cf6b2[_0x7bb1('0x1a')][_0x7bb1('0x1b')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x5cf6b2[_0x7bb1('0x1a')]?_0x5cf6b2[_0x7bb1('0x1a')]['where']||null:null,'attributes':_0x5cf6b2[_0x7bb1('0x1a')]?_0x5cf6b2[_0x7bb1('0x1a')][_0x7bb1('0x1c')]||null:null,'limit':_0x5cf6b2[_0x7bb1('0x1a')]?_0x5cf6b2['options'][_0x7bb1('0x1d')]||null:null})[_0x7bb1('0x11')](function(_0x114414){logger[_0x7bb1('0x12')](_0x7bb1('0x17'),_0x5cf6b2);logger[_0x7bb1('0x1e')]('UpdateOpenchannelInteraction',_0x5cf6b2,JSON['stringify'](_0x114414));_0x1fb05c(_0x114414);})[_0x7bb1('0x1f')](function(_0x30407b){logger['error'](_0x7bb1('0x17'),_0x30407b[_0x7bb1('0x16')],_0x5cf6b2);_0x3360f3(_0x253593['error'](0x1f4,_0x30407b['message']));});});};exports[_0x7bb1('0x20')]=function(_0x46bdcd){return new Promise(function(_0x476b97,_0x4249dd){return db[_0x7bb1('0x21')]['find']({'where':_0x46bdcd['options']?_0x46bdcd[_0x7bb1('0x1a')][_0x7bb1('0x22')]||null:null})[_0x7bb1('0x11')](function(_0x244c53){if(_0x244c53){return _0x244c53[_0x7bb1('0x23')](_0x46bdcd[_0x7bb1('0x19')][_0x7bb1('0x24')],_[_0x7bb1('0x25')](_0x46bdcd[_0x7bb1('0x19')],[_0x7bb1('0x24'),'id'])||{});}})[_0x7bb1('0x26')](function(_0x1d9b78){logger['info'](_0x7bb1('0x27'),_0x46bdcd);logger[_0x7bb1('0x1e')]('AddTags',_0x46bdcd,JSON['stringify'](_0x1d9b78));_0x476b97(_0x1d9b78);})[_0x7bb1('0x1f')](function(_0x2148e3){logger[_0x7bb1('0x14')](_0x7bb1('0x27'),_0x2148e3[_0x7bb1('0x16')],_0x46bdcd);_0x4249dd(_this[_0x7bb1('0x14')](0x1f4,_0x2148e3[_0x7bb1('0x16')]));});});};