Built motion from commit (unavailable).|2.5.2
[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 _0x121c=['defaults','localhost','socket.io-emitter','./openchannelInteraction.socket','request','info','OpenchannelInteraction,\x20%s,\x20%s','request\x20sent','debug','error','message','result','UpdateOpenchannelInteraction','body','options','raw','limit','then','catch','AddTagsToOpenchannelInteraction','OpenchannelInteraction','where','ids','spread','AddTags','stringify','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','redis'];(function(_0x435df5,_0x5ddfe7){var _0x33a898=function(_0x13d023){while(--_0x13d023){_0x435df5['push'](_0x435df5['shift']());}};_0x33a898(++_0x5ddfe7);}(_0x121c,0xd8));var _0xc121=function(_0x411add,_0x1aed38){_0x411add=_0x411add-0x0;var _0x238242=_0x121c[_0x411add];return _0x238242;};'use strict';var _=require('lodash');var util=require(_0xc121('0x0'));var moment=require('moment');var BPromise=require(_0xc121('0x1'));var rs=require(_0xc121('0x2'));var fs=require('fs');var Redis=require(_0xc121('0x3'));var db=require(_0xc121('0x4'))['db'];var utils=require(_0xc121('0x5'));var logger=require(_0xc121('0x6'))(_0xc121('0x7'));var config=require('../../config/environment');var jayson=require(_0xc121('0x8'));var client=jayson[_0xc121('0x9')][_0xc121('0xa')]({'port':0x232a});config[_0xc121('0xb')]=_[_0xc121('0xc')](config['redis'],{'host':_0xc121('0xd'),'port':0x18eb});var socket=require(_0xc121('0xe'))(new Redis(config['redis']));require(_0xc121('0xf'))['register'](socket);function respondWithRpcPromise(_0x417a24,_0x3e9f16,_0x5f37df){return new BPromise(function(_0x1601eb,_0x4443f3){return client[_0xc121('0x10')](_0x417a24,_0x5f37df)['then'](function(_0x529b70){logger[_0xc121('0x11')](_0xc121('0x12'),_0x3e9f16,_0xc121('0x13'));logger[_0xc121('0x14')]('OpenchannelInteraction,\x20%s,\x20%s,\x20%s',_0x3e9f16,_0xc121('0x13'),JSON['stringify'](_0x529b70));if(_0x529b70[_0xc121('0x15')]){if(_0x529b70[_0xc121('0x15')]['code']===0x1f4){logger[_0xc121('0x15')](_0xc121('0x12'),_0x3e9f16,_0x529b70[_0xc121('0x15')][_0xc121('0x16')]);return _0x4443f3(_0x529b70[_0xc121('0x15')][_0xc121('0x16')]);}logger['error'](_0xc121('0x12'),_0x3e9f16,_0x529b70['error'][_0xc121('0x16')]);return _0x1601eb(_0x529b70[_0xc121('0x15')]['message']);}else{logger['info'](_0xc121('0x12'),_0x3e9f16,_0xc121('0x13'));_0x1601eb(_0x529b70[_0xc121('0x17')][_0xc121('0x16')]);}})['catch'](function(_0x5ca4b0){logger[_0xc121('0x15')](_0xc121('0x12'),_0x3e9f16,_0x5ca4b0);_0x4443f3(_0x5ca4b0);});});}exports[_0xc121('0x18')]=function(_0x27fece){var _0x3212bc=this;return new Promise(function(_0x3f6e17,_0x174c66){return db['OpenchannelInteraction']['update'](_0x27fece[_0xc121('0x19')],{'raw':_0x27fece[_0xc121('0x1a')]?_0x27fece[_0xc121('0x1a')][_0xc121('0x1b')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x27fece[_0xc121('0x1a')]?_0x27fece[_0xc121('0x1a')]['where']||null:null,'attributes':_0x27fece[_0xc121('0x1a')]?_0x27fece[_0xc121('0x1a')]['attributes']||null:null,'limit':_0x27fece['options']?_0x27fece[_0xc121('0x1a')][_0xc121('0x1c')]||null:null})[_0xc121('0x1d')](function(_0x5060a2){logger[_0xc121('0x11')](_0xc121('0x18'),_0x27fece);logger[_0xc121('0x14')]('UpdateOpenchannelInteraction',_0x27fece,JSON['stringify'](_0x5060a2));_0x3f6e17(_0x5060a2);})[_0xc121('0x1e')](function(_0x5011d3){logger[_0xc121('0x15')](_0xc121('0x18'),_0x5011d3[_0xc121('0x16')],_0x27fece);_0x174c66(_0x3212bc[_0xc121('0x15')](0x1f4,_0x5011d3[_0xc121('0x16')]));});});};exports[_0xc121('0x1f')]=function(_0x2a99d6){return new Promise(function(_0x48d930,_0x37baf0){return db[_0xc121('0x20')]['find']({'where':_0x2a99d6[_0xc121('0x1a')]?_0x2a99d6[_0xc121('0x1a')][_0xc121('0x21')]||null:null})[_0xc121('0x1d')](function(_0x205345){if(_0x205345){return _0x205345['addTags'](_0x2a99d6[_0xc121('0x19')][_0xc121('0x22')],_['omit'](_0x2a99d6['body'],[_0xc121('0x22'),'id'])||{});}})[_0xc121('0x23')](function(_0x58efef){logger['info'](_0xc121('0x24'),_0x2a99d6);logger[_0xc121('0x14')](_0xc121('0x24'),_0x2a99d6,JSON[_0xc121('0x25')](_0x58efef));_0x48d930(_0x58efef);})['catch'](function(_0x5c4a8a){logger[_0xc121('0x15')](_0xc121('0x24'),_0x5c4a8a[_0xc121('0x16')],_0x2a99d6);_0x37baf0(_this['error'](0x1f4,_0x5c4a8a[_0xc121('0x16')]));});});};