c8414842a5acdc74c79386256a24dab82403e146
[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 _0xb71b=['socket.io-emitter','./openchannelInteraction.socket','then','info','request\x20sent','OpenchannelInteraction,\x20%s,\x20%s,\x20%s','error','code','OpenchannelInteraction,\x20%s,\x20%s','message','result','catch','UpdateOpenchannelInteraction','OpenchannelInteraction','update','options','raw','where','attributes','limit','debug','stringify','AddTagsToOpenchannelInteraction','body','ids','spread','AddTags','lodash','util','moment','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','redis'];(function(_0x4c779c,_0x5ce627){var _0x5988a8=function(_0x26f64b){while(--_0x26f64b){_0x4c779c['push'](_0x4c779c['shift']());}};_0x5988a8(++_0x5ce627);}(_0xb71b,0x1e3));var _0xbb71=function(_0x2c969d,_0x9ba36f){_0x2c969d=_0x2c969d-0x0;var _0x442132=_0xb71b[_0x2c969d];return _0x442132;};'use strict';var _=require(_0xbb71('0x0'));var util=require(_0xbb71('0x1'));var moment=require(_0xbb71('0x2'));var BPromise=require('bluebird');var rs=require(_0xbb71('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xbb71('0x4'))['db'];var utils=require(_0xbb71('0x5'));var logger=require(_0xbb71('0x6'))(_0xbb71('0x7'));var config=require(_0xbb71('0x8'));var jayson=require(_0xbb71('0x9'));var client=jayson['client']['http']({'port':0x232a});config[_0xbb71('0xa')]=_['defaults'](config[_0xbb71('0xa')],{'host':'localhost','port':0x18eb});var socket=require(_0xbb71('0xb'))(new Redis(config[_0xbb71('0xa')]));require(_0xbb71('0xc'))['register'](socket);function respondWithRpcPromise(_0x25263c,_0x56ce41,_0x4cfdc0){return new BPromise(function(_0xe14e7,_0x14379e){return client['request'](_0x25263c,_0x4cfdc0)[_0xbb71('0xd')](function(_0x1996cc){logger[_0xbb71('0xe')]('OpenchannelInteraction,\x20%s,\x20%s',_0x56ce41,_0xbb71('0xf'));logger['debug'](_0xbb71('0x10'),_0x56ce41,_0xbb71('0xf'),JSON['stringify'](_0x1996cc));if(_0x1996cc[_0xbb71('0x11')]){if(_0x1996cc['error'][_0xbb71('0x12')]===0x1f4){logger[_0xbb71('0x11')](_0xbb71('0x13'),_0x56ce41,_0x1996cc[_0xbb71('0x11')]['message']);return _0x14379e(_0x1996cc[_0xbb71('0x11')][_0xbb71('0x14')]);}logger[_0xbb71('0x11')](_0xbb71('0x13'),_0x56ce41,_0x1996cc[_0xbb71('0x11')][_0xbb71('0x14')]);return _0xe14e7(_0x1996cc[_0xbb71('0x11')]['message']);}else{logger['info'](_0xbb71('0x13'),_0x56ce41,_0xbb71('0xf'));_0xe14e7(_0x1996cc[_0xbb71('0x15')][_0xbb71('0x14')]);}})[_0xbb71('0x16')](function(_0x42a0bd){logger[_0xbb71('0x11')]('OpenchannelInteraction,\x20%s,\x20%s',_0x56ce41,_0x42a0bd);_0x14379e(_0x42a0bd);});});}exports[_0xbb71('0x17')]=function(_0x30d1c3){var _0x5a3467=this;return new Promise(function(_0x477b24,_0x5e4f49){return db[_0xbb71('0x18')][_0xbb71('0x19')](_0x30d1c3['body'],{'raw':_0x30d1c3['options']?_0x30d1c3[_0xbb71('0x1a')][_0xbb71('0x1b')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x30d1c3['options']?_0x30d1c3[_0xbb71('0x1a')][_0xbb71('0x1c')]||null:null,'attributes':_0x30d1c3['options']?_0x30d1c3['options'][_0xbb71('0x1d')]||null:null,'limit':_0x30d1c3['options']?_0x30d1c3[_0xbb71('0x1a')][_0xbb71('0x1e')]||null:null})[_0xbb71('0xd')](function(_0x399266){logger[_0xbb71('0xe')](_0xbb71('0x17'),_0x30d1c3);logger[_0xbb71('0x1f')](_0xbb71('0x17'),_0x30d1c3,JSON[_0xbb71('0x20')](_0x399266));_0x477b24(_0x399266);})[_0xbb71('0x16')](function(_0x2bbc95){logger['error'](_0xbb71('0x17'),_0x2bbc95[_0xbb71('0x14')],_0x30d1c3);_0x5e4f49(_0x5a3467[_0xbb71('0x11')](0x1f4,_0x2bbc95[_0xbb71('0x14')]));});});};exports[_0xbb71('0x21')]=function(_0x16fc74){return new Promise(function(_0x17c17e,_0x15dcd6){return db[_0xbb71('0x18')]['find']({'where':_0x16fc74[_0xbb71('0x1a')]?_0x16fc74[_0xbb71('0x1a')]['where']||null:null})['then'](function(_0x363a3e){if(_0x363a3e){return _0x363a3e['addTags'](_0x16fc74[_0xbb71('0x22')][_0xbb71('0x23')],_['omit'](_0x16fc74[_0xbb71('0x22')],[_0xbb71('0x23'),'id'])||{});}})[_0xbb71('0x24')](function(_0x54fb5a){logger[_0xbb71('0xe')](_0xbb71('0x25'),_0x16fc74);logger[_0xbb71('0x1f')]('AddTags',_0x16fc74,JSON[_0xbb71('0x20')](_0x54fb5a));_0x17c17e(_0x54fb5a);})[_0xbb71('0x16')](function(_0x1c8bad){logger[_0xbb71('0x11')]('AddTags',_0x1c8bad['message'],_0x16fc74);_0x15dcd6(_this[_0xbb71('0x11')](0x1f4,_0x1c8bad['message']));});});};