Built motion from commit 9d0783e6.|2.6.13
[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 _0xf145=['request','OpenchannelInteraction,\x20%s,\x20%s','request\x20sent','debug','error','code','message','info','result','UpdateOpenchannelInteraction','OpenchannelInteraction','update','body','options','raw','where','attributes','AddTagsToOpenchannelInteraction','then','ids','omit','spread','AddTags','stringify','lodash','util','randomstring','../../mysqldb','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','./openchannelInteraction.socket','register'];(function(_0x502773,_0xe55d92){var _0x568f34=function(_0x44a7f9){while(--_0x44a7f9){_0x502773['push'](_0x502773['shift']());}};_0x568f34(++_0xe55d92);}(_0xf145,0x8a));var _0x5f14=function(_0x331ce0,_0xe335b9){_0x331ce0=_0x331ce0-0x0;var _0x31c3c7=_0xf145[_0x331ce0];return _0x31c3c7;};'use strict';var _=require(_0x5f14('0x0'));var util=require(_0x5f14('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x5f14('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x5f14('0x3'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x5f14('0x4'));var config=require(_0x5f14('0x5'));var jayson=require(_0x5f14('0x6'));var client=jayson[_0x5f14('0x7')][_0x5f14('0x8')]({'port':0x232a});config[_0x5f14('0x9')]=_[_0x5f14('0xa')](config[_0x5f14('0x9')],{'host':_0x5f14('0xb'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x5f14('0xc'))[_0x5f14('0xd')](socket);function respondWithRpcPromise(_0x1d9816,_0x247d46,_0x14de75){return new BPromise(function(_0x40ba49,_0x3e337b){return client[_0x5f14('0xe')](_0x1d9816,_0x14de75)['then'](function(_0x55f619){logger['info'](_0x5f14('0xf'),_0x247d46,_0x5f14('0x10'));logger[_0x5f14('0x11')]('OpenchannelInteraction,\x20%s,\x20%s,\x20%s',_0x247d46,_0x5f14('0x10'),JSON['stringify'](_0x55f619));if(_0x55f619[_0x5f14('0x12')]){if(_0x55f619['error'][_0x5f14('0x13')]===0x1f4){logger[_0x5f14('0x12')]('OpenchannelInteraction,\x20%s,\x20%s',_0x247d46,_0x55f619[_0x5f14('0x12')]['message']);return _0x3e337b(_0x55f619['error'][_0x5f14('0x14')]);}logger[_0x5f14('0x12')]('OpenchannelInteraction,\x20%s,\x20%s',_0x247d46,_0x55f619[_0x5f14('0x12')][_0x5f14('0x14')]);return _0x40ba49(_0x55f619[_0x5f14('0x12')]['message']);}else{logger[_0x5f14('0x15')](_0x5f14('0xf'),_0x247d46,_0x5f14('0x10'));_0x40ba49(_0x55f619[_0x5f14('0x16')][_0x5f14('0x14')]);}})['catch'](function(_0x5a476b){logger[_0x5f14('0x12')](_0x5f14('0xf'),_0x247d46,_0x5a476b);_0x3e337b(_0x5a476b);});});}exports[_0x5f14('0x17')]=function(_0x23b8ec){var _0x179bcc=this;return new Promise(function(_0x34b521,_0x1b839f){return db[_0x5f14('0x18')][_0x5f14('0x19')](_0x23b8ec[_0x5f14('0x1a')],{'raw':_0x23b8ec[_0x5f14('0x1b')]?_0x23b8ec[_0x5f14('0x1b')][_0x5f14('0x1c')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x23b8ec['options']?_0x23b8ec[_0x5f14('0x1b')][_0x5f14('0x1d')]||null:null,'attributes':_0x23b8ec[_0x5f14('0x1b')]?_0x23b8ec[_0x5f14('0x1b')][_0x5f14('0x1e')]||null:null,'limit':_0x23b8ec[_0x5f14('0x1b')]?_0x23b8ec['options']['limit']||null:null})['then'](function(_0xd32bd2){logger[_0x5f14('0x15')](_0x5f14('0x17'),_0x23b8ec);logger[_0x5f14('0x11')](_0x5f14('0x17'),_0x23b8ec,JSON['stringify'](_0xd32bd2));_0x34b521(_0xd32bd2);})['catch'](function(_0x114542){logger[_0x5f14('0x12')](_0x5f14('0x17'),_0x114542['message'],_0x23b8ec);_0x1b839f(_0x179bcc[_0x5f14('0x12')](0x1f4,_0x114542[_0x5f14('0x14')]));});});};exports[_0x5f14('0x1f')]=function(_0x46719){return new Promise(function(_0x484e0a,_0x592697){return db['OpenchannelInteraction']['find']({'where':_0x46719[_0x5f14('0x1b')]?_0x46719[_0x5f14('0x1b')]['where']||null:null})[_0x5f14('0x20')](function(_0x1757d7){if(_0x1757d7){return _0x1757d7['addTags'](_0x46719['body'][_0x5f14('0x21')],_[_0x5f14('0x22')](_0x46719[_0x5f14('0x1a')],[_0x5f14('0x21'),'id'])||{});}})[_0x5f14('0x23')](function(_0x207d8b){logger[_0x5f14('0x15')]('AddTags',_0x46719);logger[_0x5f14('0x11')](_0x5f14('0x24'),_0x46719,JSON[_0x5f14('0x25')](_0x207d8b));_0x484e0a(_0x207d8b);})['catch'](function(_0x1846ff){logger[_0x5f14('0x12')]('AddTags',_0x1846ff[_0x5f14('0x14')],_0x46719);_0x592697(_this['error'](0x1f4,_0x1846ff[_0x5f14('0x14')]));});});};