Built motion from commit (unavailable).|2.5.31
[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 _0xea85=['info','OpenchannelInteraction,\x20%s,\x20%s','request\x20sent','debug','OpenchannelInteraction,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','OpenchannelInteraction','update','options','where','attributes','limit','UpdateOpenchannelInteraction','find','addTags','body','ids','omit','AddTags','lodash','util','moment','randomstring','ioredis','../../config/logger','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./openchannelInteraction.socket','request','then'];(function(_0x49cb52,_0x543fd2){var _0x17a838=function(_0x1b5aaa){while(--_0x1b5aaa){_0x49cb52['push'](_0x49cb52['shift']());}};_0x17a838(++_0x543fd2);}(_0xea85,0x6a));var _0x5ea8=function(_0x7cda5c,_0x20e430){_0x7cda5c=_0x7cda5c-0x0;var _0x5d1cc4=_0xea85[_0x7cda5c];return _0x5d1cc4;};'use strict';var _=require(_0x5ea8('0x0'));var util=require(_0x5ea8('0x1'));var moment=require(_0x5ea8('0x2'));var BPromise=require('bluebird');var rs=require(_0x5ea8('0x3'));var fs=require('fs');var Redis=require(_0x5ea8('0x4'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x5ea8('0x5'))('rpc');var config=require(_0x5ea8('0x6'));var jayson=require(_0x5ea8('0x7'));var client=jayson[_0x5ea8('0x8')][_0x5ea8('0x9')]({'port':0x232a});config[_0x5ea8('0xa')]=_[_0x5ea8('0xb')](config[_0x5ea8('0xa')],{'host':_0x5ea8('0xc'),'port':0x18eb});var socket=require(_0x5ea8('0xd'))(new Redis(config['redis']));require(_0x5ea8('0xe'))['register'](socket);function respondWithRpcPromise(_0x5b514b,_0x154dbb,_0x32366a){return new BPromise(function(_0x4c85c8,_0x252dac){return client[_0x5ea8('0xf')](_0x5b514b,_0x32366a)[_0x5ea8('0x10')](function(_0x35f776){logger[_0x5ea8('0x11')](_0x5ea8('0x12'),_0x154dbb,_0x5ea8('0x13'));logger[_0x5ea8('0x14')](_0x5ea8('0x15'),_0x154dbb,_0x5ea8('0x13'),JSON[_0x5ea8('0x16')](_0x35f776));if(_0x35f776[_0x5ea8('0x17')]){if(_0x35f776[_0x5ea8('0x17')][_0x5ea8('0x18')]===0x1f4){logger[_0x5ea8('0x17')](_0x5ea8('0x12'),_0x154dbb,_0x35f776[_0x5ea8('0x17')][_0x5ea8('0x19')]);return _0x252dac(_0x35f776['error'][_0x5ea8('0x19')]);}logger[_0x5ea8('0x17')]('OpenchannelInteraction,\x20%s,\x20%s',_0x154dbb,_0x35f776[_0x5ea8('0x17')]['message']);return _0x4c85c8(_0x35f776[_0x5ea8('0x17')][_0x5ea8('0x19')]);}else{logger[_0x5ea8('0x11')](_0x5ea8('0x12'),_0x154dbb,_0x5ea8('0x13'));_0x4c85c8(_0x35f776[_0x5ea8('0x1a')][_0x5ea8('0x19')]);}})[_0x5ea8('0x1b')](function(_0x6339ac){logger[_0x5ea8('0x17')](_0x5ea8('0x12'),_0x154dbb,_0x6339ac);_0x252dac(_0x6339ac);});});}exports['UpdateOpenchannelInteraction']=function(_0x512408){var _0x5397c3=this;return new Promise(function(_0x5684d4,_0x35f00b){return db[_0x5ea8('0x1c')][_0x5ea8('0x1d')](_0x512408['body'],{'raw':_0x512408['options']?_0x512408[_0x5ea8('0x1e')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x512408[_0x5ea8('0x1e')]?_0x512408['options'][_0x5ea8('0x1f')]||null:null,'attributes':_0x512408[_0x5ea8('0x1e')]?_0x512408[_0x5ea8('0x1e')][_0x5ea8('0x20')]||null:null,'limit':_0x512408[_0x5ea8('0x1e')]?_0x512408['options'][_0x5ea8('0x21')]||null:null})['then'](function(_0x56acde){logger[_0x5ea8('0x11')](_0x5ea8('0x22'),_0x512408);logger[_0x5ea8('0x14')](_0x5ea8('0x22'),_0x512408,JSON['stringify'](_0x56acde));_0x5684d4(_0x56acde);})[_0x5ea8('0x1b')](function(_0x25297e){logger['error'](_0x5ea8('0x22'),_0x25297e[_0x5ea8('0x19')],_0x512408);_0x35f00b(_0x5397c3['error'](0x1f4,_0x25297e['message']));});});};exports['AddTagsToOpenchannelInteraction']=function(_0x49e60e){return new Promise(function(_0x812613,_0xd1fae8){return db[_0x5ea8('0x1c')][_0x5ea8('0x23')]({'where':_0x49e60e[_0x5ea8('0x1e')]?_0x49e60e[_0x5ea8('0x1e')][_0x5ea8('0x1f')]||null:null})[_0x5ea8('0x10')](function(_0x24f701){if(_0x24f701){return _0x24f701[_0x5ea8('0x24')](_0x49e60e[_0x5ea8('0x25')][_0x5ea8('0x26')],_[_0x5ea8('0x27')](_0x49e60e[_0x5ea8('0x25')],[_0x5ea8('0x26'),'id'])||{});}})['spread'](function(_0x276e94){logger[_0x5ea8('0x11')]('AddTags',_0x49e60e);logger['debug']('AddTags',_0x49e60e,JSON[_0x5ea8('0x16')](_0x276e94));_0x812613(_0x276e94);})['catch'](function(_0x576705){logger[_0x5ea8('0x17')](_0x5ea8('0x28'),_0x576705[_0x5ea8('0x19')],_0x49e60e);_0xd1fae8(_this['error'](0x1f4,_0x576705['message']));});});};