de8c57352d23dfd70c6a0da88c06a86bd35e66d8
[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 _0xf857=['client','http','defaults','redis','localhost','socket.io-emitter','./openchannelInteraction.socket','request','then','info','OpenchannelInteraction,\x20%s,\x20%s','request\x20sent','debug','OpenchannelInteraction,\x20%s,\x20%s,\x20%s','stringify','error','message','catch','UpdateOpenchannelInteraction','OpenchannelInteraction','update','body','raw','options','where','attributes','limit','AddTagsToOpenchannelInteraction','addTags','ids','omit','AddTags','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise'];(function(_0x15f3c0,_0x165a64){var _0x1adfe0=function(_0x212cfc){while(--_0x212cfc){_0x15f3c0['push'](_0x15f3c0['shift']());}};_0x1adfe0(++_0x165a64);}(_0xf857,0x1d8));var _0x7f85=function(_0x1ffe76,_0x552dad){_0x1ffe76=_0x1ffe76-0x0;var _0x17a24e=_0xf857[_0x1ffe76];return _0x17a24e;};'use strict';var _=require(_0x7f85('0x0'));var util=require(_0x7f85('0x1'));var moment=require(_0x7f85('0x2'));var BPromise=require(_0x7f85('0x3'));var rs=require(_0x7f85('0x4'));var fs=require('fs');var Redis=require(_0x7f85('0x5'));var db=require(_0x7f85('0x6'))['db'];var utils=require(_0x7f85('0x7'));var logger=require(_0x7f85('0x8'))(_0x7f85('0x9'));var config=require(_0x7f85('0xa'));var jayson=require(_0x7f85('0xb'));var client=jayson[_0x7f85('0xc')][_0x7f85('0xd')]({'port':0x232a});config['redis']=_[_0x7f85('0xe')](config[_0x7f85('0xf')],{'host':_0x7f85('0x10'),'port':0x18eb});var socket=require(_0x7f85('0x11'))(new Redis(config[_0x7f85('0xf')]));require(_0x7f85('0x12'))['register'](socket);function respondWithRpcPromise(_0x31f2a1,_0x25bc69,_0x38cb06){return new BPromise(function(_0x44c5bc,_0x932477){return client[_0x7f85('0x13')](_0x31f2a1,_0x38cb06)[_0x7f85('0x14')](function(_0x4b694a){logger[_0x7f85('0x15')](_0x7f85('0x16'),_0x25bc69,_0x7f85('0x17'));logger[_0x7f85('0x18')](_0x7f85('0x19'),_0x25bc69,'request\x20sent',JSON[_0x7f85('0x1a')](_0x4b694a));if(_0x4b694a[_0x7f85('0x1b')]){if(_0x4b694a[_0x7f85('0x1b')]['code']===0x1f4){logger['error'](_0x7f85('0x16'),_0x25bc69,_0x4b694a[_0x7f85('0x1b')][_0x7f85('0x1c')]);return _0x932477(_0x4b694a[_0x7f85('0x1b')][_0x7f85('0x1c')]);}logger[_0x7f85('0x1b')]('OpenchannelInteraction,\x20%s,\x20%s',_0x25bc69,_0x4b694a[_0x7f85('0x1b')][_0x7f85('0x1c')]);return _0x44c5bc(_0x4b694a[_0x7f85('0x1b')][_0x7f85('0x1c')]);}else{logger['info'](_0x7f85('0x16'),_0x25bc69,'request\x20sent');_0x44c5bc(_0x4b694a['result']['message']);}})[_0x7f85('0x1d')](function(_0x2b9987){logger[_0x7f85('0x1b')](_0x7f85('0x16'),_0x25bc69,_0x2b9987);_0x932477(_0x2b9987);});});}exports[_0x7f85('0x1e')]=function(_0x194aed){var _0x64764=this;return new Promise(function(_0x236059,_0xc5abb9){return db[_0x7f85('0x1f')][_0x7f85('0x20')](_0x194aed[_0x7f85('0x21')],{'raw':_0x194aed['options']?_0x194aed['options'][_0x7f85('0x22')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x194aed[_0x7f85('0x23')]?_0x194aed[_0x7f85('0x23')][_0x7f85('0x24')]||null:null,'attributes':_0x194aed[_0x7f85('0x23')]?_0x194aed['options'][_0x7f85('0x25')]||null:null,'limit':_0x194aed[_0x7f85('0x23')]?_0x194aed['options'][_0x7f85('0x26')]||null:null})[_0x7f85('0x14')](function(_0x189e44){logger[_0x7f85('0x15')](_0x7f85('0x1e'),_0x194aed);logger[_0x7f85('0x18')](_0x7f85('0x1e'),_0x194aed,JSON[_0x7f85('0x1a')](_0x189e44));_0x236059(_0x189e44);})['catch'](function(_0x6e6c37){logger[_0x7f85('0x1b')]('UpdateOpenchannelInteraction',_0x6e6c37[_0x7f85('0x1c')],_0x194aed);_0xc5abb9(_0x64764['error'](0x1f4,_0x6e6c37[_0x7f85('0x1c')]));});});};exports[_0x7f85('0x27')]=function(_0x42f03c){return new Promise(function(_0x1ddf29,_0x2b0806){return db[_0x7f85('0x1f')]['find']({'where':_0x42f03c[_0x7f85('0x23')]?_0x42f03c['options'][_0x7f85('0x24')]||null:null})[_0x7f85('0x14')](function(_0x356933){if(_0x356933){return _0x356933[_0x7f85('0x28')](_0x42f03c[_0x7f85('0x21')][_0x7f85('0x29')],_[_0x7f85('0x2a')](_0x42f03c[_0x7f85('0x21')],[_0x7f85('0x29'),'id'])||{});}})['spread'](function(_0x52ddbf){logger[_0x7f85('0x15')](_0x7f85('0x2b'),_0x42f03c);logger[_0x7f85('0x18')](_0x7f85('0x2b'),_0x42f03c,JSON['stringify'](_0x52ddbf));_0x1ddf29(_0x52ddbf);})[_0x7f85('0x1d')](function(_0x1400f5){logger[_0x7f85('0x1b')](_0x7f85('0x2b'),_0x1400f5[_0x7f85('0x1c')],_0x42f03c);_0x2b0806(_this[_0x7f85('0x1b')](0x1f4,_0x1400f5[_0x7f85('0x1c')]));});});};