62e6348df39bffe5a486cc919d493aa615b93af1
[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 _0x556b=['OpenchannelInteraction,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','UpdateOpenchannelInteraction','update','options','raw','where','attributes','AddTagsToOpenchannelInteraction','find','addTags','body','ids','AddTags','lodash','util','moment','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','register','request','then','info','OpenchannelInteraction,\x20%s,\x20%s','request\x20sent','debug'];(function(_0x695faa,_0x2d55f6){var _0x42a4fa=function(_0x1d0634){while(--_0x1d0634){_0x695faa['push'](_0x695faa['shift']());}};_0x42a4fa(++_0x2d55f6);}(_0x556b,0x8a));var _0xb556=function(_0x266f67,_0x360ca4){_0x266f67=_0x266f67-0x0;var _0x42d604=_0x556b[_0x266f67];return _0x42d604;};'use strict';var _=require(_0xb556('0x0'));var util=require(_0xb556('0x1'));var moment=require(_0xb556('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xb556('0x3'));var db=require(_0xb556('0x4'))['db'];var utils=require(_0xb556('0x5'));var logger=require(_0xb556('0x6'))('rpc');var config=require(_0xb556('0x7'));var jayson=require(_0xb556('0x8'));var client=jayson[_0xb556('0x9')][_0xb556('0xa')]({'port':0x232a});config[_0xb556('0xb')]=_[_0xb556('0xc')](config[_0xb556('0xb')],{'host':_0xb556('0xd'),'port':0x18eb});var socket=require(_0xb556('0xe'))(new Redis(config[_0xb556('0xb')]));require('./openchannelInteraction.socket')[_0xb556('0xf')](socket);function respondWithRpcPromise(_0x2ae188,_0x2bff9e,_0x4c782b){return new BPromise(function(_0xa15b62,_0x4853b3){return client[_0xb556('0x10')](_0x2ae188,_0x4c782b)[_0xb556('0x11')](function(_0x349128){logger[_0xb556('0x12')](_0xb556('0x13'),_0x2bff9e,_0xb556('0x14'));logger[_0xb556('0x15')](_0xb556('0x16'),_0x2bff9e,'request\x20sent',JSON[_0xb556('0x17')](_0x349128));if(_0x349128[_0xb556('0x18')]){if(_0x349128[_0xb556('0x18')]['code']===0x1f4){logger[_0xb556('0x18')](_0xb556('0x13'),_0x2bff9e,_0x349128[_0xb556('0x18')][_0xb556('0x19')]);return _0x4853b3(_0x349128[_0xb556('0x18')][_0xb556('0x19')]);}logger[_0xb556('0x18')](_0xb556('0x13'),_0x2bff9e,_0x349128[_0xb556('0x18')][_0xb556('0x19')]);return _0xa15b62(_0x349128[_0xb556('0x18')][_0xb556('0x19')]);}else{logger[_0xb556('0x12')](_0xb556('0x13'),_0x2bff9e,_0xb556('0x14'));_0xa15b62(_0x349128[_0xb556('0x1a')]['message']);}})[_0xb556('0x1b')](function(_0x1e695d){logger[_0xb556('0x18')](_0xb556('0x13'),_0x2bff9e,_0x1e695d);_0x4853b3(_0x1e695d);});});}exports[_0xb556('0x1c')]=function(_0x153789){var _0x4a2e3f=this;return new Promise(function(_0x470829,_0x2d7a21){return db['OpenchannelInteraction'][_0xb556('0x1d')](_0x153789['body'],{'raw':_0x153789[_0xb556('0x1e')]?_0x153789[_0xb556('0x1e')][_0xb556('0x1f')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x153789[_0xb556('0x1e')]?_0x153789[_0xb556('0x1e')][_0xb556('0x20')]||null:null,'attributes':_0x153789[_0xb556('0x1e')]?_0x153789[_0xb556('0x1e')][_0xb556('0x21')]||null:null,'limit':_0x153789[_0xb556('0x1e')]?_0x153789[_0xb556('0x1e')]['limit']||null:null})['then'](function(_0xad91cf){logger[_0xb556('0x12')]('UpdateOpenchannelInteraction',_0x153789);logger[_0xb556('0x15')](_0xb556('0x1c'),_0x153789,JSON[_0xb556('0x17')](_0xad91cf));_0x470829(_0xad91cf);})[_0xb556('0x1b')](function(_0x52f20c){logger[_0xb556('0x18')](_0xb556('0x1c'),_0x52f20c[_0xb556('0x19')],_0x153789);_0x2d7a21(_0x4a2e3f[_0xb556('0x18')](0x1f4,_0x52f20c[_0xb556('0x19')]));});});};exports[_0xb556('0x22')]=function(_0x279892){return new Promise(function(_0x55e8b9,_0x50391b){return db['OpenchannelInteraction'][_0xb556('0x23')]({'where':_0x279892[_0xb556('0x1e')]?_0x279892[_0xb556('0x1e')]['where']||null:null})[_0xb556('0x11')](function(_0xcaae2e){if(_0xcaae2e){return _0xcaae2e[_0xb556('0x24')](_0x279892['body']['ids'],_['omit'](_0x279892[_0xb556('0x25')],[_0xb556('0x26'),'id'])||{});}})['spread'](function(_0x4fb802){logger[_0xb556('0x12')](_0xb556('0x27'),_0x279892);logger['debug'](_0xb556('0x27'),_0x279892,JSON[_0xb556('0x17')](_0x4fb802));_0x55e8b9(_0x4fb802);})[_0xb556('0x1b')](function(_0x3480c8){logger['error'](_0xb556('0x27'),_0x3480c8[_0xb556('0x19')],_0x279892);_0x50391b(_this[_0xb556('0x18')](0x1f4,_0x3480c8[_0xb556('0x19')]));});});};