1c91c0e93f57e65b580686ba5c8450ae8087a8bd
[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 _0x5170=['addTags','ids','omit','spread','AddTags','util','moment','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','socket.io-emitter','./openchannelInteraction.socket','register','request','then','info','OpenchannelInteraction,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','catch','OpenchannelInteraction','body','options','where','attributes','limit','UpdateOpenchannelInteraction','AddTagsToOpenchannelInteraction','find'];(function(_0x48c518,_0x198466){var _0x1899c4=function(_0x44fad1){while(--_0x44fad1){_0x48c518['push'](_0x48c518['shift']());}};_0x1899c4(++_0x198466);}(_0x5170,0x19f));var _0x0517=function(_0x85fb1d,_0x91e4c9){_0x85fb1d=_0x85fb1d-0x0;var _0x21c228=_0x5170[_0x85fb1d];return _0x21c228;};'use strict';var _=require('lodash');var util=require(_0x0517('0x0'));var moment=require(_0x0517('0x1'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x0517('0x2'));var db=require(_0x0517('0x3'))['db'];var utils=require(_0x0517('0x4'));var logger=require(_0x0517('0x5'))(_0x0517('0x6'));var config=require(_0x0517('0x7'));var jayson=require(_0x0517('0x8'));var client=jayson[_0x0517('0x9')][_0x0517('0xa')]({'port':0x232a});config[_0x0517('0xb')]=_[_0x0517('0xc')](config[_0x0517('0xb')],{'host':'localhost','port':0x18eb});var socket=require(_0x0517('0xd'))(new Redis(config['redis']));require(_0x0517('0xe'))[_0x0517('0xf')](socket);function respondWithRpcPromise(_0xc89c15,_0x422a20,_0x4ef9e9){return new BPromise(function(_0x3e1ef9,_0x17422e){return client[_0x0517('0x10')](_0xc89c15,_0x4ef9e9)[_0x0517('0x11')](function(_0x181175){logger[_0x0517('0x12')](_0x0517('0x13'),_0x422a20,_0x0517('0x14'));logger[_0x0517('0x15')]('OpenchannelInteraction,\x20%s,\x20%s,\x20%s',_0x422a20,_0x0517('0x14'),JSON[_0x0517('0x16')](_0x181175));if(_0x181175['error']){if(_0x181175[_0x0517('0x17')][_0x0517('0x18')]===0x1f4){logger[_0x0517('0x17')](_0x0517('0x13'),_0x422a20,_0x181175[_0x0517('0x17')][_0x0517('0x19')]);return _0x17422e(_0x181175['error'][_0x0517('0x19')]);}logger[_0x0517('0x17')](_0x0517('0x13'),_0x422a20,_0x181175[_0x0517('0x17')]['message']);return _0x3e1ef9(_0x181175[_0x0517('0x17')][_0x0517('0x19')]);}else{logger[_0x0517('0x12')](_0x0517('0x13'),_0x422a20,_0x0517('0x14'));_0x3e1ef9(_0x181175['result'][_0x0517('0x19')]);}})[_0x0517('0x1a')](function(_0x52d8a8){logger[_0x0517('0x17')]('OpenchannelInteraction,\x20%s,\x20%s',_0x422a20,_0x52d8a8);_0x17422e(_0x52d8a8);});});}exports['UpdateOpenchannelInteraction']=function(_0x54a766){var _0x3c4767=this;return new Promise(function(_0x35bc7c,_0x21b920){return db[_0x0517('0x1b')]['update'](_0x54a766[_0x0517('0x1c')],{'raw':_0x54a766[_0x0517('0x1d')]?_0x54a766[_0x0517('0x1d')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x54a766[_0x0517('0x1d')]?_0x54a766[_0x0517('0x1d')][_0x0517('0x1e')]||null:null,'attributes':_0x54a766[_0x0517('0x1d')]?_0x54a766[_0x0517('0x1d')][_0x0517('0x1f')]||null:null,'limit':_0x54a766['options']?_0x54a766['options'][_0x0517('0x20')]||null:null})[_0x0517('0x11')](function(_0x3e3d77){logger[_0x0517('0x12')](_0x0517('0x21'),_0x54a766);logger[_0x0517('0x15')](_0x0517('0x21'),_0x54a766,JSON['stringify'](_0x3e3d77));_0x35bc7c(_0x3e3d77);})[_0x0517('0x1a')](function(_0x5ef11c){logger[_0x0517('0x17')](_0x0517('0x21'),_0x5ef11c[_0x0517('0x19')],_0x54a766);_0x21b920(_0x3c4767[_0x0517('0x17')](0x1f4,_0x5ef11c[_0x0517('0x19')]));});});};exports[_0x0517('0x22')]=function(_0x444b23){return new Promise(function(_0x20cd36,_0x19dc65){return db[_0x0517('0x1b')][_0x0517('0x23')]({'where':_0x444b23[_0x0517('0x1d')]?_0x444b23[_0x0517('0x1d')][_0x0517('0x1e')]||null:null})[_0x0517('0x11')](function(_0x23504a){if(_0x23504a){return _0x23504a[_0x0517('0x24')](_0x444b23[_0x0517('0x1c')][_0x0517('0x25')],_[_0x0517('0x26')](_0x444b23[_0x0517('0x1c')],[_0x0517('0x25'),'id'])||{});}})[_0x0517('0x27')](function(_0x38fb1f){logger[_0x0517('0x12')](_0x0517('0x28'),_0x444b23);logger['debug'](_0x0517('0x28'),_0x444b23,JSON['stringify'](_0x38fb1f));_0x20cd36(_0x38fb1f);})['catch'](function(_0x22475b){logger['error'](_0x0517('0x28'),_0x22475b[_0x0517('0x19')],_0x444b23);_0x19dc65(_this['error'](0x1f4,_0x22475b[_0x0517('0x19')]));});});};