dec8e34c58d3d256e96395d7218202c958641b35
[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 _0x0c97=['AddTags','stringify','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','client','redis','defaults','socket.io-emitter','./openchannelInteraction.socket','register','request','info','request\x20sent','debug','OpenchannelInteraction,\x20%s,\x20%s,\x20%s','code','error','OpenchannelInteraction,\x20%s,\x20%s','message','result','catch','update','body','options','raw','where','attributes','UpdateOpenchannelInteraction','AddTagsToOpenchannelInteraction','OpenchannelInteraction','find','then','addTags','ids'];(function(_0x4645bd,_0x1ad4c){var _0x59ebbb=function(_0x42f66f){while(--_0x42f66f){_0x4645bd['push'](_0x4645bd['shift']());}};_0x59ebbb(++_0x1ad4c);}(_0x0c97,0x7d));var _0x70c9=function(_0xb66df,_0x4fb5ce){_0xb66df=_0xb66df-0x0;var _0x42a702=_0x0c97[_0xb66df];return _0x42a702;};'use strict';var _=require(_0x70c9('0x0'));var util=require(_0x70c9('0x1'));var moment=require('moment');var BPromise=require(_0x70c9('0x2'));var rs=require(_0x70c9('0x3'));var fs=require('fs');var Redis=require(_0x70c9('0x4'));var db=require(_0x70c9('0x5'))['db'];var utils=require(_0x70c9('0x6'));var logger=require(_0x70c9('0x7'))(_0x70c9('0x8'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x70c9('0x9')]['http']({'port':0x232a});config[_0x70c9('0xa')]=_[_0x70c9('0xb')](config[_0x70c9('0xa')],{'host':'localhost','port':0x18eb});var socket=require(_0x70c9('0xc'))(new Redis(config[_0x70c9('0xa')]));require(_0x70c9('0xd'))[_0x70c9('0xe')](socket);function respondWithRpcPromise(_0x1efa4b,_0x485f5b,_0x425512){return new BPromise(function(_0x2443e6,_0x3f5d9f){return client[_0x70c9('0xf')](_0x1efa4b,_0x425512)['then'](function(_0x48352a){logger[_0x70c9('0x10')]('OpenchannelInteraction,\x20%s,\x20%s',_0x485f5b,_0x70c9('0x11'));logger[_0x70c9('0x12')](_0x70c9('0x13'),_0x485f5b,_0x70c9('0x11'),JSON['stringify'](_0x48352a));if(_0x48352a['error']){if(_0x48352a['error'][_0x70c9('0x14')]===0x1f4){logger[_0x70c9('0x15')](_0x70c9('0x16'),_0x485f5b,_0x48352a[_0x70c9('0x15')][_0x70c9('0x17')]);return _0x3f5d9f(_0x48352a[_0x70c9('0x15')][_0x70c9('0x17')]);}logger[_0x70c9('0x15')]('OpenchannelInteraction,\x20%s,\x20%s',_0x485f5b,_0x48352a['error'][_0x70c9('0x17')]);return _0x2443e6(_0x48352a[_0x70c9('0x15')][_0x70c9('0x17')]);}else{logger['info'](_0x70c9('0x16'),_0x485f5b,'request\x20sent');_0x2443e6(_0x48352a[_0x70c9('0x18')]['message']);}})[_0x70c9('0x19')](function(_0x30391c){logger[_0x70c9('0x15')](_0x70c9('0x16'),_0x485f5b,_0x30391c);_0x3f5d9f(_0x30391c);});});}exports['UpdateOpenchannelInteraction']=function(_0x58bccc){var _0x99d7c3=this;return new Promise(function(_0x2dff01,_0x2893ac){return db['OpenchannelInteraction'][_0x70c9('0x1a')](_0x58bccc[_0x70c9('0x1b')],{'raw':_0x58bccc[_0x70c9('0x1c')]?_0x58bccc[_0x70c9('0x1c')][_0x70c9('0x1d')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x58bccc['options']?_0x58bccc[_0x70c9('0x1c')][_0x70c9('0x1e')]||null:null,'attributes':_0x58bccc[_0x70c9('0x1c')]?_0x58bccc['options'][_0x70c9('0x1f')]||null:null,'limit':_0x58bccc[_0x70c9('0x1c')]?_0x58bccc[_0x70c9('0x1c')]['limit']||null:null})['then'](function(_0x4e3169){logger[_0x70c9('0x10')]('UpdateOpenchannelInteraction',_0x58bccc);logger['debug']('UpdateOpenchannelInteraction',_0x58bccc,JSON['stringify'](_0x4e3169));_0x2dff01(_0x4e3169);})[_0x70c9('0x19')](function(_0x43d585){logger[_0x70c9('0x15')](_0x70c9('0x20'),_0x43d585[_0x70c9('0x17')],_0x58bccc);_0x2893ac(_0x99d7c3['error'](0x1f4,_0x43d585[_0x70c9('0x17')]));});});};exports[_0x70c9('0x21')]=function(_0x1d5eb7){return new Promise(function(_0x399d83,_0x5a9d4b){return db[_0x70c9('0x22')][_0x70c9('0x23')]({'where':_0x1d5eb7[_0x70c9('0x1c')]?_0x1d5eb7[_0x70c9('0x1c')][_0x70c9('0x1e')]||null:null})[_0x70c9('0x24')](function(_0x3f6cea){if(_0x3f6cea){return _0x3f6cea[_0x70c9('0x25')](_0x1d5eb7['body'][_0x70c9('0x26')],_['omit'](_0x1d5eb7[_0x70c9('0x1b')],[_0x70c9('0x26'),'id'])||{});}})['spread'](function(_0x5bfcee){logger['info'](_0x70c9('0x27'),_0x1d5eb7);logger['debug'](_0x70c9('0x27'),_0x1d5eb7,JSON[_0x70c9('0x28')](_0x5bfcee));_0x399d83(_0x5bfcee);})[_0x70c9('0x19')](function(_0x41aa9f){logger[_0x70c9('0x15')]('AddTags',_0x41aa9f[_0x70c9('0x17')],_0x1d5eb7);_0x5a9d4b(_this['error'](0x1f4,_0x41aa9f['message']));});});};