Built motion from commit f74363e9.|2.6.34
[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 _0xb744=['OpenchannelInteraction,\x20%s,\x20%s','message','result','catch','UpdateOpenchannelInteraction','OpenchannelInteraction','update','body','options','raw','where','attributes','limit','AddTagsToOpenchannelInteraction','find','addTags','ids','omit','spread','AddTags','lodash','util','moment','bluebird','ioredis','../../mysqldb','rpc','jayson/promise','http','redis','localhost','socket.io-emitter','./openchannelInteraction.socket','register','request','then','info','request\x20sent','debug','OpenchannelInteraction,\x20%s,\x20%s,\x20%s','stringify','error'];(function(_0x19e873,_0x1059ee){var _0x29491a=function(_0x258d35){while(--_0x258d35){_0x19e873['push'](_0x19e873['shift']());}};_0x29491a(++_0x1059ee);}(_0xb744,0x92));var _0x4b74=function(_0x4e16ed,_0x46c804){_0x4e16ed=_0x4e16ed-0x0;var _0x3e27c0=_0xb744[_0x4e16ed];return _0x3e27c0;};'use strict';var _=require(_0x4b74('0x0'));var util=require(_0x4b74('0x1'));var moment=require(_0x4b74('0x2'));var BPromise=require(_0x4b74('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x4b74('0x4'));var db=require(_0x4b74('0x5'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x4b74('0x6'));var config=require('../../config/environment');var jayson=require(_0x4b74('0x7'));var client=jayson['client'][_0x4b74('0x8')]({'port':0x232a});config[_0x4b74('0x9')]=_['defaults'](config['redis'],{'host':_0x4b74('0xa'),'port':0x18eb});var socket=require(_0x4b74('0xb'))(new Redis(config['redis']));require(_0x4b74('0xc'))[_0x4b74('0xd')](socket);function respondWithRpcPromise(_0x21c2d8,_0x2156a7,_0x1d6b56){return new BPromise(function(_0x5821a1,_0x9311a){return client[_0x4b74('0xe')](_0x21c2d8,_0x1d6b56)[_0x4b74('0xf')](function(_0x5be8f6){logger[_0x4b74('0x10')]('OpenchannelInteraction,\x20%s,\x20%s',_0x2156a7,_0x4b74('0x11'));logger[_0x4b74('0x12')](_0x4b74('0x13'),_0x2156a7,'request\x20sent',JSON[_0x4b74('0x14')](_0x5be8f6));if(_0x5be8f6[_0x4b74('0x15')]){if(_0x5be8f6[_0x4b74('0x15')]['code']===0x1f4){logger[_0x4b74('0x15')](_0x4b74('0x16'),_0x2156a7,_0x5be8f6[_0x4b74('0x15')][_0x4b74('0x17')]);return _0x9311a(_0x5be8f6[_0x4b74('0x15')][_0x4b74('0x17')]);}logger[_0x4b74('0x15')](_0x4b74('0x16'),_0x2156a7,_0x5be8f6[_0x4b74('0x15')][_0x4b74('0x17')]);return _0x5821a1(_0x5be8f6['error'][_0x4b74('0x17')]);}else{logger[_0x4b74('0x10')](_0x4b74('0x16'),_0x2156a7,'request\x20sent');_0x5821a1(_0x5be8f6[_0x4b74('0x18')][_0x4b74('0x17')]);}})[_0x4b74('0x19')](function(_0x48989e){logger['error'](_0x4b74('0x16'),_0x2156a7,_0x48989e);_0x9311a(_0x48989e);});});}exports[_0x4b74('0x1a')]=function(_0x9504f2){var _0x18f5b0=this;return new Promise(function(_0x5ad918,_0x3c29ef){return db[_0x4b74('0x1b')][_0x4b74('0x1c')](_0x9504f2[_0x4b74('0x1d')],{'raw':_0x9504f2[_0x4b74('0x1e')]?_0x9504f2[_0x4b74('0x1e')][_0x4b74('0x1f')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x9504f2[_0x4b74('0x1e')]?_0x9504f2['options'][_0x4b74('0x20')]||null:null,'attributes':_0x9504f2[_0x4b74('0x1e')]?_0x9504f2[_0x4b74('0x1e')][_0x4b74('0x21')]||null:null,'limit':_0x9504f2[_0x4b74('0x1e')]?_0x9504f2['options'][_0x4b74('0x22')]||null:null})[_0x4b74('0xf')](function(_0x4e91d8){logger[_0x4b74('0x10')](_0x4b74('0x1a'),_0x9504f2);logger[_0x4b74('0x12')](_0x4b74('0x1a'),_0x9504f2,JSON[_0x4b74('0x14')](_0x4e91d8));_0x5ad918(_0x4e91d8);})[_0x4b74('0x19')](function(_0x1daec6){logger[_0x4b74('0x15')](_0x4b74('0x1a'),_0x1daec6[_0x4b74('0x17')],_0x9504f2);_0x3c29ef(_0x18f5b0[_0x4b74('0x15')](0x1f4,_0x1daec6[_0x4b74('0x17')]));});});};exports[_0x4b74('0x23')]=function(_0x58cea7){return new Promise(function(_0x10d4bb,_0x56a7cd){return db['OpenchannelInteraction'][_0x4b74('0x24')]({'where':_0x58cea7[_0x4b74('0x1e')]?_0x58cea7[_0x4b74('0x1e')]['where']||null:null})[_0x4b74('0xf')](function(_0x16d11e){if(_0x16d11e){return _0x16d11e[_0x4b74('0x25')](_0x58cea7['body'][_0x4b74('0x26')],_[_0x4b74('0x27')](_0x58cea7['body'],[_0x4b74('0x26'),'id'])||{});}})[_0x4b74('0x28')](function(_0x2c27cc){logger[_0x4b74('0x10')](_0x4b74('0x29'),_0x58cea7);logger['debug']('AddTags',_0x58cea7,JSON[_0x4b74('0x14')](_0x2c27cc));_0x10d4bb(_0x2c27cc);})[_0x4b74('0x19')](function(_0x2e0594){logger['error']('AddTags',_0x2e0594[_0x4b74('0x17')],_0x58cea7);_0x56a7cd(_this['error'](0x1f4,_0x2e0594[_0x4b74('0x17')]));});});};