Built motion from commit 5ae82ce5.|2.6.7
[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 _0x0f55=['request\x20sent','debug','OpenchannelInteraction,\x20%s,\x20%s,\x20%s','stringify','error','message','OpenchannelInteraction,\x20%s,\x20%s','result','catch','UpdateOpenchannelInteraction','OpenchannelInteraction','update','raw','options','where','limit','then','AddTagsToOpenchannelInteraction','addTags','body','omit','ids','spread','AddTags','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','redis','defaults','socket.io-emitter','./openchannelInteraction.socket','register','request','info'];(function(_0x59a3dd,_0xad48e3){var _0x18aec7=function(_0xdfb2e1){while(--_0xdfb2e1){_0x59a3dd['push'](_0x59a3dd['shift']());}};_0x18aec7(++_0xad48e3);}(_0x0f55,0xbc));var _0x50f5=function(_0x4d7a61,_0x3fb6e6){_0x4d7a61=_0x4d7a61-0x0;var _0x186f73=_0x0f55[_0x4d7a61];return _0x186f73;};'use strict';var _=require(_0x50f5('0x0'));var util=require(_0x50f5('0x1'));var moment=require(_0x50f5('0x2'));var BPromise=require('bluebird');var rs=require(_0x50f5('0x3'));var fs=require('fs');var Redis=require(_0x50f5('0x4'));var db=require(_0x50f5('0x5'))['db'];var utils=require(_0x50f5('0x6'));var logger=require(_0x50f5('0x7'))('rpc');var config=require(_0x50f5('0x8'));var jayson=require(_0x50f5('0x9'));var client=jayson['client']['http']({'port':0x232a});config[_0x50f5('0xa')]=_[_0x50f5('0xb')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x50f5('0xc'))(new Redis(config[_0x50f5('0xa')]));require(_0x50f5('0xd'))[_0x50f5('0xe')](socket);function respondWithRpcPromise(_0x28e5a2,_0xd2420e,_0x43a430){return new BPromise(function(_0x204be9,_0x529449){return client[_0x50f5('0xf')](_0x28e5a2,_0x43a430)['then'](function(_0x1ad0e2){logger[_0x50f5('0x10')]('OpenchannelInteraction,\x20%s,\x20%s',_0xd2420e,_0x50f5('0x11'));logger[_0x50f5('0x12')](_0x50f5('0x13'),_0xd2420e,_0x50f5('0x11'),JSON[_0x50f5('0x14')](_0x1ad0e2));if(_0x1ad0e2[_0x50f5('0x15')]){if(_0x1ad0e2[_0x50f5('0x15')]['code']===0x1f4){logger[_0x50f5('0x15')]('OpenchannelInteraction,\x20%s,\x20%s',_0xd2420e,_0x1ad0e2[_0x50f5('0x15')]['message']);return _0x529449(_0x1ad0e2[_0x50f5('0x15')][_0x50f5('0x16')]);}logger[_0x50f5('0x15')](_0x50f5('0x17'),_0xd2420e,_0x1ad0e2['error'][_0x50f5('0x16')]);return _0x204be9(_0x1ad0e2['error'][_0x50f5('0x16')]);}else{logger[_0x50f5('0x10')]('OpenchannelInteraction,\x20%s,\x20%s',_0xd2420e,_0x50f5('0x11'));_0x204be9(_0x1ad0e2[_0x50f5('0x18')][_0x50f5('0x16')]);}})[_0x50f5('0x19')](function(_0x54bb41){logger[_0x50f5('0x15')]('OpenchannelInteraction,\x20%s,\x20%s',_0xd2420e,_0x54bb41);_0x529449(_0x54bb41);});});}exports[_0x50f5('0x1a')]=function(_0x4abb65){var _0x40e865=this;return new Promise(function(_0x1afed5,_0x4aa29e){return db[_0x50f5('0x1b')][_0x50f5('0x1c')](_0x4abb65['body'],{'raw':_0x4abb65['options']?_0x4abb65['options'][_0x50f5('0x1d')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x4abb65[_0x50f5('0x1e')]?_0x4abb65[_0x50f5('0x1e')][_0x50f5('0x1f')]||null:null,'attributes':_0x4abb65[_0x50f5('0x1e')]?_0x4abb65[_0x50f5('0x1e')]['attributes']||null:null,'limit':_0x4abb65[_0x50f5('0x1e')]?_0x4abb65[_0x50f5('0x1e')][_0x50f5('0x20')]||null:null})[_0x50f5('0x21')](function(_0x525bd0){logger[_0x50f5('0x10')]('UpdateOpenchannelInteraction',_0x4abb65);logger[_0x50f5('0x12')](_0x50f5('0x1a'),_0x4abb65,JSON['stringify'](_0x525bd0));_0x1afed5(_0x525bd0);})[_0x50f5('0x19')](function(_0x56648a){logger[_0x50f5('0x15')](_0x50f5('0x1a'),_0x56648a[_0x50f5('0x16')],_0x4abb65);_0x4aa29e(_0x40e865['error'](0x1f4,_0x56648a['message']));});});};exports[_0x50f5('0x22')]=function(_0x2565b4){return new Promise(function(_0x73cea8,_0x5e4a17){return db[_0x50f5('0x1b')]['find']({'where':_0x2565b4[_0x50f5('0x1e')]?_0x2565b4[_0x50f5('0x1e')][_0x50f5('0x1f')]||null:null})['then'](function(_0x48e224){if(_0x48e224){return _0x48e224[_0x50f5('0x23')](_0x2565b4[_0x50f5('0x24')]['ids'],_[_0x50f5('0x25')](_0x2565b4[_0x50f5('0x24')],[_0x50f5('0x26'),'id'])||{});}})[_0x50f5('0x27')](function(_0x368980){logger['info']('AddTags',_0x2565b4);logger['debug'](_0x50f5('0x28'),_0x2565b4,JSON['stringify'](_0x368980));_0x73cea8(_0x368980);})[_0x50f5('0x19')](function(_0x5207a1){logger['error'](_0x50f5('0x28'),_0x5207a1[_0x50f5('0x16')],_0x2565b4);_0x5e4a17(_this['error'](0x1f4,_0x5207a1[_0x50f5('0x16')]));});});};