Built motion from commit ffdca78c.|2.6.24
[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 _0x216b=['raw','where','limit','AddTagsToOpenchannelInteraction','find','addTags','body','omit','ids','spread','AddTags','stringify','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','jayson/promise','client','redis','defaults','./openchannelInteraction.socket','request','then','OpenchannelInteraction,\x20%s,\x20%s','request\x20sent','debug','error','message','info','result','catch','UpdateOpenchannelInteraction','OpenchannelInteraction','update','options'];(function(_0x22af96,_0x55ba2c){var _0x3e1fd4=function(_0x4f38b4){while(--_0x4f38b4){_0x22af96['push'](_0x22af96['shift']());}};_0x3e1fd4(++_0x55ba2c);}(_0x216b,0xcf));var _0xb216=function(_0x4c681a,_0xa30696){_0x4c681a=_0x4c681a-0x0;var _0x5064bb=_0x216b[_0x4c681a];return _0x5064bb;};'use strict';var _=require(_0xb216('0x0'));var util=require(_0xb216('0x1'));var moment=require(_0xb216('0x2'));var BPromise=require(_0xb216('0x3'));var rs=require(_0xb216('0x4'));var fs=require('fs');var Redis=require(_0xb216('0x5'));var db=require(_0xb216('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0xb216('0x7'))('rpc');var config=require('../../config/environment');var jayson=require(_0xb216('0x8'));var client=jayson[_0xb216('0x9')]['http']({'port':0x232a});config[_0xb216('0xa')]=_[_0xb216('0xb')](config[_0xb216('0xa')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0xb216('0xc'))['register'](socket);function respondWithRpcPromise(_0x1ecb45,_0xb6670,_0x4ef906){return new BPromise(function(_0x14d0ea,_0x1d3e39){return client[_0xb216('0xd')](_0x1ecb45,_0x4ef906)[_0xb216('0xe')](function(_0x238061){logger['info'](_0xb216('0xf'),_0xb6670,_0xb216('0x10'));logger[_0xb216('0x11')]('OpenchannelInteraction,\x20%s,\x20%s,\x20%s',_0xb6670,'request\x20sent',JSON['stringify'](_0x238061));if(_0x238061[_0xb216('0x12')]){if(_0x238061[_0xb216('0x12')]['code']===0x1f4){logger['error'](_0xb216('0xf'),_0xb6670,_0x238061[_0xb216('0x12')][_0xb216('0x13')]);return _0x1d3e39(_0x238061['error'][_0xb216('0x13')]);}logger[_0xb216('0x12')](_0xb216('0xf'),_0xb6670,_0x238061[_0xb216('0x12')]['message']);return _0x14d0ea(_0x238061[_0xb216('0x12')]['message']);}else{logger[_0xb216('0x14')](_0xb216('0xf'),_0xb6670,_0xb216('0x10'));_0x14d0ea(_0x238061[_0xb216('0x15')][_0xb216('0x13')]);}})[_0xb216('0x16')](function(_0x11c8df){logger['error']('OpenchannelInteraction,\x20%s,\x20%s',_0xb6670,_0x11c8df);_0x1d3e39(_0x11c8df);});});}exports[_0xb216('0x17')]=function(_0x300752){var _0x32605b=this;return new Promise(function(_0x32be9f,_0x55a714){return db[_0xb216('0x18')][_0xb216('0x19')](_0x300752['body'],{'raw':_0x300752['options']?_0x300752[_0xb216('0x1a')][_0xb216('0x1b')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x300752[_0xb216('0x1a')]?_0x300752['options'][_0xb216('0x1c')]||null:null,'attributes':_0x300752['options']?_0x300752['options']['attributes']||null:null,'limit':_0x300752['options']?_0x300752[_0xb216('0x1a')][_0xb216('0x1d')]||null:null})[_0xb216('0xe')](function(_0xc388ab){logger[_0xb216('0x14')]('UpdateOpenchannelInteraction',_0x300752);logger[_0xb216('0x11')](_0xb216('0x17'),_0x300752,JSON['stringify'](_0xc388ab));_0x32be9f(_0xc388ab);})[_0xb216('0x16')](function(_0xc0dbba){logger['error'](_0xb216('0x17'),_0xc0dbba['message'],_0x300752);_0x55a714(_0x32605b['error'](0x1f4,_0xc0dbba[_0xb216('0x13')]));});});};exports[_0xb216('0x1e')]=function(_0x236b16){return new Promise(function(_0x34a5ad,_0x3d8851){return db[_0xb216('0x18')][_0xb216('0x1f')]({'where':_0x236b16[_0xb216('0x1a')]?_0x236b16['options'][_0xb216('0x1c')]||null:null})[_0xb216('0xe')](function(_0x36d6d5){if(_0x36d6d5){return _0x36d6d5[_0xb216('0x20')](_0x236b16[_0xb216('0x21')]['ids'],_[_0xb216('0x22')](_0x236b16[_0xb216('0x21')],[_0xb216('0x23'),'id'])||{});}})[_0xb216('0x24')](function(_0x29702f){logger[_0xb216('0x14')](_0xb216('0x25'),_0x236b16);logger[_0xb216('0x11')](_0xb216('0x25'),_0x236b16,JSON[_0xb216('0x26')](_0x29702f));_0x34a5ad(_0x29702f);})[_0xb216('0x16')](function(_0x55ac44){logger[_0xb216('0x12')](_0xb216('0x25'),_0x55ac44[_0xb216('0x13')],_0x236b16);_0x3d8851(_this[_0xb216('0x12')](0x1f4,_0x55ac44[_0xb216('0x13')]));});});};