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 _0xbdcb=['stringify','code','error','OpenchannelInteraction,\x20%s,\x20%s','message','OpenchannelInteraction','update','body','options','raw','UpdateOpenchannelInteraction','debug','catch','AddTagsToOpenchannelInteraction','find','where','ids','omit','AddTags','lodash','util','moment','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','defaults','redis','localhost','socket.io-emitter','./openchannelInteraction.socket','register','request','then','info','request\x20sent','OpenchannelInteraction,\x20%s,\x20%s,\x20%s'];(function(_0x3eb717,_0xf575a0){var _0x58f2e7=function(_0x18b29b){while(--_0x18b29b){_0x3eb717['push'](_0x3eb717['shift']());}};_0x58f2e7(++_0xf575a0);}(_0xbdcb,0x65));var _0xbbdc=function(_0x40220a,_0x22feb1){_0x40220a=_0x40220a-0x0;var _0x3903cc=_0xbdcb[_0x40220a];return _0x3903cc;};'use strict';var _=require(_0xbbdc('0x0'));var util=require(_0xbbdc('0x1'));var moment=require(_0xbbdc('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xbbdc('0x3'));var db=require(_0xbbdc('0x4'))['db'];var utils=require(_0xbbdc('0x5'));var logger=require(_0xbbdc('0x6'))('rpc');var config=require(_0xbbdc('0x7'));var jayson=require(_0xbbdc('0x8'));var client=jayson[_0xbbdc('0x9')][_0xbbdc('0xa')]({'port':0x232a});config['redis']=_[_0xbbdc('0xb')](config[_0xbbdc('0xc')],{'host':_0xbbdc('0xd'),'port':0x18eb});var socket=require(_0xbbdc('0xe'))(new Redis(config['redis']));require(_0xbbdc('0xf'))[_0xbbdc('0x10')](socket);function respondWithRpcPromise(_0x57083d,_0x4b9b41,_0x2170ab){return new BPromise(function(_0x5388eb,_0x1890c3){return client[_0xbbdc('0x11')](_0x57083d,_0x2170ab)[_0xbbdc('0x12')](function(_0x19bbe8){logger[_0xbbdc('0x13')]('OpenchannelInteraction,\x20%s,\x20%s',_0x4b9b41,_0xbbdc('0x14'));logger['debug'](_0xbbdc('0x15'),_0x4b9b41,_0xbbdc('0x14'),JSON[_0xbbdc('0x16')](_0x19bbe8));if(_0x19bbe8['error']){if(_0x19bbe8['error'][_0xbbdc('0x17')]===0x1f4){logger[_0xbbdc('0x18')](_0xbbdc('0x19'),_0x4b9b41,_0x19bbe8[_0xbbdc('0x18')][_0xbbdc('0x1a')]);return _0x1890c3(_0x19bbe8[_0xbbdc('0x18')][_0xbbdc('0x1a')]);}logger[_0xbbdc('0x18')]('OpenchannelInteraction,\x20%s,\x20%s',_0x4b9b41,_0x19bbe8[_0xbbdc('0x18')]['message']);return _0x5388eb(_0x19bbe8[_0xbbdc('0x18')][_0xbbdc('0x1a')]);}else{logger[_0xbbdc('0x13')](_0xbbdc('0x19'),_0x4b9b41,'request\x20sent');_0x5388eb(_0x19bbe8['result'][_0xbbdc('0x1a')]);}})['catch'](function(_0x3b4748){logger[_0xbbdc('0x18')]('OpenchannelInteraction,\x20%s,\x20%s',_0x4b9b41,_0x3b4748);_0x1890c3(_0x3b4748);});});}exports['UpdateOpenchannelInteraction']=function(_0x50b48b){var _0x5eab59=this;return new Promise(function(_0x1be9d4,_0x358981){return db[_0xbbdc('0x1b')][_0xbbdc('0x1c')](_0x50b48b[_0xbbdc('0x1d')],{'raw':_0x50b48b[_0xbbdc('0x1e')]?_0x50b48b[_0xbbdc('0x1e')][_0xbbdc('0x1f')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x50b48b['options']?_0x50b48b[_0xbbdc('0x1e')]['where']||null:null,'attributes':_0x50b48b[_0xbbdc('0x1e')]?_0x50b48b[_0xbbdc('0x1e')]['attributes']||null:null,'limit':_0x50b48b['options']?_0x50b48b[_0xbbdc('0x1e')]['limit']||null:null})[_0xbbdc('0x12')](function(_0x70acfd){logger[_0xbbdc('0x13')](_0xbbdc('0x20'),_0x50b48b);logger[_0xbbdc('0x21')](_0xbbdc('0x20'),_0x50b48b,JSON[_0xbbdc('0x16')](_0x70acfd));_0x1be9d4(_0x70acfd);})[_0xbbdc('0x22')](function(_0x91a70e){logger[_0xbbdc('0x18')](_0xbbdc('0x20'),_0x91a70e['message'],_0x50b48b);_0x358981(_0x5eab59[_0xbbdc('0x18')](0x1f4,_0x91a70e[_0xbbdc('0x1a')]));});});};exports[_0xbbdc('0x23')]=function(_0xc72295){return new Promise(function(_0x251ebb,_0x1f19fe){return db[_0xbbdc('0x1b')][_0xbbdc('0x24')]({'where':_0xc72295[_0xbbdc('0x1e')]?_0xc72295[_0xbbdc('0x1e')][_0xbbdc('0x25')]||null:null})['then'](function(_0x576035){if(_0x576035){return _0x576035['addTags'](_0xc72295[_0xbbdc('0x1d')][_0xbbdc('0x26')],_[_0xbbdc('0x27')](_0xc72295[_0xbbdc('0x1d')],['ids','id'])||{});}})['spread'](function(_0x5c3dc9){logger[_0xbbdc('0x13')]('AddTags',_0xc72295);logger[_0xbbdc('0x21')](_0xbbdc('0x28'),_0xc72295,JSON[_0xbbdc('0x16')](_0x5c3dc9));_0x251ebb(_0x5c3dc9);})['catch'](function(_0x18875f){logger[_0xbbdc('0x18')](_0xbbdc('0x28'),_0x18875f[_0xbbdc('0x1a')],_0xc72295);_0x1f19fe(_this['error'](0x1f4,_0x18875f['message']));});});};