a75ee01845cc0943b6f34d0b4e93e918797d6c7f
[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 _0x610b=['debug','OpenchannelInteraction,\x20%s,\x20%s,\x20%s','stringify','error','code','message','OpenchannelInteraction,\x20%s,\x20%s','info','catch','UpdateOpenchannelInteraction','update','body','options','raw','where','attributes','AddTagsToOpenchannelInteraction','find','addTags','ids','omit','spread','AddTags','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','client','http','redis','defaults','localhost','register','request','then','request\x20sent'];(function(_0x1a343c,_0x2b5378){var _0x440d4c=function(_0x275cbc){while(--_0x275cbc){_0x1a343c['push'](_0x1a343c['shift']());}};_0x440d4c(++_0x2b5378);}(_0x610b,0x1e5));var _0xb610=function(_0x53d384,_0x99e6a0){_0x53d384=_0x53d384-0x0;var _0x182c9a=_0x610b[_0x53d384];return _0x182c9a;};'use strict';var _=require(_0xb610('0x0'));var util=require(_0xb610('0x1'));var moment=require(_0xb610('0x2'));var BPromise=require(_0xb610('0x3'));var rs=require(_0xb610('0x4'));var fs=require('fs');var Redis=require(_0xb610('0x5'));var db=require(_0xb610('0x6'))['db'];var utils=require(_0xb610('0x7'));var logger=require(_0xb610('0x8'))('rpc');var config=require(_0xb610('0x9'));var jayson=require('jayson/promise');var client=jayson[_0xb610('0xa')][_0xb610('0xb')]({'port':0x232a});config[_0xb610('0xc')]=_[_0xb610('0xd')](config[_0xb610('0xc')],{'host':_0xb610('0xe'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xb610('0xc')]));require('./openchannelInteraction.socket')[_0xb610('0xf')](socket);function respondWithRpcPromise(_0x1ea7a4,_0x1e6ae9,_0x4112c6){return new BPromise(function(_0x2d8307,_0x5f1178){return client[_0xb610('0x10')](_0x1ea7a4,_0x4112c6)[_0xb610('0x11')](function(_0x2e1dad){logger['info']('OpenchannelInteraction,\x20%s,\x20%s',_0x1e6ae9,_0xb610('0x12'));logger[_0xb610('0x13')](_0xb610('0x14'),_0x1e6ae9,'request\x20sent',JSON[_0xb610('0x15')](_0x2e1dad));if(_0x2e1dad[_0xb610('0x16')]){if(_0x2e1dad[_0xb610('0x16')][_0xb610('0x17')]===0x1f4){logger[_0xb610('0x16')]('OpenchannelInteraction,\x20%s,\x20%s',_0x1e6ae9,_0x2e1dad[_0xb610('0x16')]['message']);return _0x5f1178(_0x2e1dad[_0xb610('0x16')][_0xb610('0x18')]);}logger[_0xb610('0x16')](_0xb610('0x19'),_0x1e6ae9,_0x2e1dad[_0xb610('0x16')]['message']);return _0x2d8307(_0x2e1dad[_0xb610('0x16')][_0xb610('0x18')]);}else{logger[_0xb610('0x1a')](_0xb610('0x19'),_0x1e6ae9,_0xb610('0x12'));_0x2d8307(_0x2e1dad['result'][_0xb610('0x18')]);}})[_0xb610('0x1b')](function(_0x2c23e5){logger[_0xb610('0x16')](_0xb610('0x19'),_0x1e6ae9,_0x2c23e5);_0x5f1178(_0x2c23e5);});});}exports[_0xb610('0x1c')]=function(_0x253a20){var _0x215661=this;return new Promise(function(_0x16e17c,_0x270c73){return db['OpenchannelInteraction'][_0xb610('0x1d')](_0x253a20[_0xb610('0x1e')],{'raw':_0x253a20[_0xb610('0x1f')]?_0x253a20[_0xb610('0x1f')][_0xb610('0x20')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x253a20[_0xb610('0x1f')]?_0x253a20[_0xb610('0x1f')][_0xb610('0x21')]||null:null,'attributes':_0x253a20[_0xb610('0x1f')]?_0x253a20[_0xb610('0x1f')][_0xb610('0x22')]||null:null,'limit':_0x253a20[_0xb610('0x1f')]?_0x253a20[_0xb610('0x1f')]['limit']||null:null})[_0xb610('0x11')](function(_0x25acb7){logger[_0xb610('0x1a')](_0xb610('0x1c'),_0x253a20);logger[_0xb610('0x13')](_0xb610('0x1c'),_0x253a20,JSON[_0xb610('0x15')](_0x25acb7));_0x16e17c(_0x25acb7);})['catch'](function(_0x32f5dc){logger[_0xb610('0x16')](_0xb610('0x1c'),_0x32f5dc[_0xb610('0x18')],_0x253a20);_0x270c73(_0x215661[_0xb610('0x16')](0x1f4,_0x32f5dc[_0xb610('0x18')]));});});};exports[_0xb610('0x23')]=function(_0x53a5ac){return new Promise(function(_0x2390d2,_0x362586){return db['OpenchannelInteraction'][_0xb610('0x24')]({'where':_0x53a5ac[_0xb610('0x1f')]?_0x53a5ac[_0xb610('0x1f')]['where']||null:null})['then'](function(_0x50b10e){if(_0x50b10e){return _0x50b10e[_0xb610('0x25')](_0x53a5ac[_0xb610('0x1e')][_0xb610('0x26')],_[_0xb610('0x27')](_0x53a5ac[_0xb610('0x1e')],[_0xb610('0x26'),'id'])||{});}})[_0xb610('0x28')](function(_0x2560f2){logger['info'](_0xb610('0x29'),_0x53a5ac);logger[_0xb610('0x13')](_0xb610('0x29'),_0x53a5ac,JSON[_0xb610('0x15')](_0x2560f2));_0x2390d2(_0x2560f2);})['catch'](function(_0x50fee7){logger[_0xb610('0x16')](_0xb610('0x29'),_0x50fee7[_0xb610('0x18')],_0x53a5ac);_0x362586(_this[_0xb610('0x16')](0x1f4,_0x50fee7[_0xb610('0x18')]));});});};