Built motion from commit (unavailable).|2.5.6
[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 _0x84c7=['client','http','redis','localhost','socket.io-emitter','./openchannelInteraction.socket','register','request','then','info','OpenchannelInteraction,\x20%s,\x20%s','request\x20sent','debug','OpenchannelInteraction,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','UpdateOpenchannelInteraction','OpenchannelInteraction','update','options','where','attributes','limit','find','addTags','body','ids','spread','AddTags','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger'];(function(_0x4e3c1d,_0x1de16){var _0x1093c6=function(_0x5114b4){while(--_0x5114b4){_0x4e3c1d['push'](_0x4e3c1d['shift']());}};_0x1093c6(++_0x1de16);}(_0x84c7,0x171));var _0x784c=function(_0x5537c9,_0xd981b7){_0x5537c9=_0x5537c9-0x0;var _0x259740=_0x84c7[_0x5537c9];return _0x259740;};'use strict';var _=require(_0x784c('0x0'));var util=require(_0x784c('0x1'));var moment=require(_0x784c('0x2'));var BPromise=require(_0x784c('0x3'));var rs=require(_0x784c('0x4'));var fs=require('fs');var Redis=require(_0x784c('0x5'));var db=require(_0x784c('0x6'))['db'];var utils=require(_0x784c('0x7'));var logger=require(_0x784c('0x8'))('rpc');var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x784c('0x9')][_0x784c('0xa')]({'port':0x232a});config[_0x784c('0xb')]=_['defaults'](config[_0x784c('0xb')],{'host':_0x784c('0xc'),'port':0x18eb});var socket=require(_0x784c('0xd'))(new Redis(config[_0x784c('0xb')]));require(_0x784c('0xe'))[_0x784c('0xf')](socket);function respondWithRpcPromise(_0x344d2e,_0x1e1ba1,_0x251ea8){return new BPromise(function(_0x366fed,_0x29c4a7){return client[_0x784c('0x10')](_0x344d2e,_0x251ea8)[_0x784c('0x11')](function(_0x22c9da){logger[_0x784c('0x12')](_0x784c('0x13'),_0x1e1ba1,_0x784c('0x14'));logger[_0x784c('0x15')](_0x784c('0x16'),_0x1e1ba1,_0x784c('0x14'),JSON[_0x784c('0x17')](_0x22c9da));if(_0x22c9da[_0x784c('0x18')]){if(_0x22c9da[_0x784c('0x18')][_0x784c('0x19')]===0x1f4){logger[_0x784c('0x18')]('OpenchannelInteraction,\x20%s,\x20%s',_0x1e1ba1,_0x22c9da[_0x784c('0x18')]['message']);return _0x29c4a7(_0x22c9da[_0x784c('0x18')][_0x784c('0x1a')]);}logger[_0x784c('0x18')](_0x784c('0x13'),_0x1e1ba1,_0x22c9da['error'][_0x784c('0x1a')]);return _0x366fed(_0x22c9da[_0x784c('0x18')][_0x784c('0x1a')]);}else{logger[_0x784c('0x12')](_0x784c('0x13'),_0x1e1ba1,'request\x20sent');_0x366fed(_0x22c9da[_0x784c('0x1b')]['message']);}})[_0x784c('0x1c')](function(_0x3c04d7){logger[_0x784c('0x18')](_0x784c('0x13'),_0x1e1ba1,_0x3c04d7);_0x29c4a7(_0x3c04d7);});});}exports[_0x784c('0x1d')]=function(_0xf8d850){var _0x1531c4=this;return new Promise(function(_0x5c4137,_0x2bd4c8){return db[_0x784c('0x1e')][_0x784c('0x1f')](_0xf8d850['body'],{'raw':_0xf8d850['options']?_0xf8d850[_0x784c('0x20')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0xf8d850['options']?_0xf8d850[_0x784c('0x20')][_0x784c('0x21')]||null:null,'attributes':_0xf8d850[_0x784c('0x20')]?_0xf8d850[_0x784c('0x20')][_0x784c('0x22')]||null:null,'limit':_0xf8d850[_0x784c('0x20')]?_0xf8d850[_0x784c('0x20')][_0x784c('0x23')]||null:null})[_0x784c('0x11')](function(_0x1fc029){logger[_0x784c('0x12')](_0x784c('0x1d'),_0xf8d850);logger[_0x784c('0x15')]('UpdateOpenchannelInteraction',_0xf8d850,JSON['stringify'](_0x1fc029));_0x5c4137(_0x1fc029);})['catch'](function(_0x9a56bb){logger[_0x784c('0x18')](_0x784c('0x1d'),_0x9a56bb[_0x784c('0x1a')],_0xf8d850);_0x2bd4c8(_0x1531c4[_0x784c('0x18')](0x1f4,_0x9a56bb[_0x784c('0x1a')]));});});};exports['AddTagsToOpenchannelInteraction']=function(_0x37affd){return new Promise(function(_0x53a244,_0x2baba6){return db[_0x784c('0x1e')][_0x784c('0x24')]({'where':_0x37affd[_0x784c('0x20')]?_0x37affd[_0x784c('0x20')][_0x784c('0x21')]||null:null})['then'](function(_0x1325e8){if(_0x1325e8){return _0x1325e8[_0x784c('0x25')](_0x37affd[_0x784c('0x26')][_0x784c('0x27')],_['omit'](_0x37affd[_0x784c('0x26')],[_0x784c('0x27'),'id'])||{});}})[_0x784c('0x28')](function(_0x4267fd){logger[_0x784c('0x12')](_0x784c('0x29'),_0x37affd);logger[_0x784c('0x15')](_0x784c('0x29'),_0x37affd,JSON[_0x784c('0x17')](_0x4267fd));_0x53a244(_0x4267fd);})[_0x784c('0x1c')](function(_0x3921e1){logger[_0x784c('0x18')](_0x784c('0x29'),_0x3921e1[_0x784c('0x1a')],_0x37affd);_0x2baba6(_this[_0x784c('0x18')](0x1f4,_0x3921e1[_0x784c('0x1a')]));});});};