Built motion from commit (unavailable).|2.5.10
[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 _0x6c51=['client','redis','defaults','localhost','socket.io-emitter','register','request','info','OpenchannelInteraction,\x20%s,\x20%s','request\x20sent','debug','OpenchannelInteraction,\x20%s,\x20%s,\x20%s','stringify','code','error','message','result','catch','UpdateOpenchannelInteraction','update','body','options','raw','limit','then','OpenchannelInteraction','find','addTags','omit','ids','AddTags','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise'];(function(_0x236cc0,_0xc76be8){var _0x509cc7=function(_0x461afd){while(--_0x461afd){_0x236cc0['push'](_0x236cc0['shift']());}};_0x509cc7(++_0xc76be8);}(_0x6c51,0x10f));var _0x16c5=function(_0x501510,_0x61caa9){_0x501510=_0x501510-0x0;var _0x1e6ee5=_0x6c51[_0x501510];return _0x1e6ee5;};'use strict';var _=require('lodash');var util=require(_0x16c5('0x0'));var moment=require(_0x16c5('0x1'));var BPromise=require('bluebird');var rs=require(_0x16c5('0x2'));var fs=require('fs');var Redis=require(_0x16c5('0x3'));var db=require(_0x16c5('0x4'))['db'];var utils=require(_0x16c5('0x5'));var logger=require(_0x16c5('0x6'))(_0x16c5('0x7'));var config=require('../../config/environment');var jayson=require(_0x16c5('0x8'));var client=jayson[_0x16c5('0x9')]['http']({'port':0x232a});config[_0x16c5('0xa')]=_[_0x16c5('0xb')](config[_0x16c5('0xa')],{'host':_0x16c5('0xc'),'port':0x18eb});var socket=require(_0x16c5('0xd'))(new Redis(config[_0x16c5('0xa')]));require('./openchannelInteraction.socket')[_0x16c5('0xe')](socket);function respondWithRpcPromise(_0x1396bd,_0x4a1061,_0x50cda5){return new BPromise(function(_0x23697b,_0x3a63e7){return client[_0x16c5('0xf')](_0x1396bd,_0x50cda5)['then'](function(_0x3f3199){logger[_0x16c5('0x10')](_0x16c5('0x11'),_0x4a1061,_0x16c5('0x12'));logger[_0x16c5('0x13')](_0x16c5('0x14'),_0x4a1061,'request\x20sent',JSON[_0x16c5('0x15')](_0x3f3199));if(_0x3f3199['error']){if(_0x3f3199['error'][_0x16c5('0x16')]===0x1f4){logger['error']('OpenchannelInteraction,\x20%s,\x20%s',_0x4a1061,_0x3f3199[_0x16c5('0x17')][_0x16c5('0x18')]);return _0x3a63e7(_0x3f3199['error'][_0x16c5('0x18')]);}logger[_0x16c5('0x17')]('OpenchannelInteraction,\x20%s,\x20%s',_0x4a1061,_0x3f3199[_0x16c5('0x17')][_0x16c5('0x18')]);return _0x23697b(_0x3f3199[_0x16c5('0x17')][_0x16c5('0x18')]);}else{logger[_0x16c5('0x10')](_0x16c5('0x11'),_0x4a1061,_0x16c5('0x12'));_0x23697b(_0x3f3199[_0x16c5('0x19')][_0x16c5('0x18')]);}})[_0x16c5('0x1a')](function(_0x66e39f){logger['error'](_0x16c5('0x11'),_0x4a1061,_0x66e39f);_0x3a63e7(_0x66e39f);});});}exports[_0x16c5('0x1b')]=function(_0x8061ae){var _0x3b4bac=this;return new Promise(function(_0xfd1504,_0x5e80de){return db['OpenchannelInteraction'][_0x16c5('0x1c')](_0x8061ae[_0x16c5('0x1d')],{'raw':_0x8061ae[_0x16c5('0x1e')]?_0x8061ae[_0x16c5('0x1e')][_0x16c5('0x1f')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x8061ae[_0x16c5('0x1e')]?_0x8061ae[_0x16c5('0x1e')]['where']||null:null,'attributes':_0x8061ae[_0x16c5('0x1e')]?_0x8061ae['options']['attributes']||null:null,'limit':_0x8061ae[_0x16c5('0x1e')]?_0x8061ae[_0x16c5('0x1e')][_0x16c5('0x20')]||null:null})[_0x16c5('0x21')](function(_0x46c5bf){logger[_0x16c5('0x10')](_0x16c5('0x1b'),_0x8061ae);logger['debug'](_0x16c5('0x1b'),_0x8061ae,JSON[_0x16c5('0x15')](_0x46c5bf));_0xfd1504(_0x46c5bf);})[_0x16c5('0x1a')](function(_0x5b251d){logger['error']('UpdateOpenchannelInteraction',_0x5b251d[_0x16c5('0x18')],_0x8061ae);_0x5e80de(_0x3b4bac[_0x16c5('0x17')](0x1f4,_0x5b251d[_0x16c5('0x18')]));});});};exports['AddTagsToOpenchannelInteraction']=function(_0x9794ff){return new Promise(function(_0x3f0fa1,_0x40c64f){return db[_0x16c5('0x22')][_0x16c5('0x23')]({'where':_0x9794ff[_0x16c5('0x1e')]?_0x9794ff[_0x16c5('0x1e')]['where']||null:null})[_0x16c5('0x21')](function(_0xd28c21){if(_0xd28c21){return _0xd28c21[_0x16c5('0x24')](_0x9794ff['body']['ids'],_[_0x16c5('0x25')](_0x9794ff[_0x16c5('0x1d')],[_0x16c5('0x26'),'id'])||{});}})['spread'](function(_0x15ef4e){logger['info'](_0x16c5('0x27'),_0x9794ff);logger[_0x16c5('0x13')](_0x16c5('0x27'),_0x9794ff,JSON[_0x16c5('0x15')](_0x15ef4e));_0x3f0fa1(_0x15ef4e);})[_0x16c5('0x1a')](function(_0x58d8b3){logger['error'](_0x16c5('0x27'),_0x58d8b3[_0x16c5('0x18')],_0x9794ff);_0x40c64f(_this['error'](0x1f4,_0x58d8b3[_0x16c5('0x18')]));});});};