5deed50b7bfc2e67a44e9b3e9d85ee18726d7f6a
[motion2.git] / server / api / faxInteraction / faxInteraction.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 _0xb043=['stringify','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','localhost','socket.io-emitter','./faxInteraction.socket','request','info','request\x20sent','debug','FaxInteraction,\x20%s,\x20%s,\x20%s','error','code','FaxInteraction,\x20%s,\x20%s','message','result','catch','UpdateFaxInteraction','update','options','raw','where','attributes','then','AddTagsToFaxInteraction','find','addTags','body','ids','omit','spread','AddTags'];(function(_0x113400,_0x41e19b){var _0x1fa1e4=function(_0x51e8ae){while(--_0x51e8ae){_0x113400['push'](_0x113400['shift']());}};_0x1fa1e4(++_0x41e19b);}(_0xb043,0x159));var _0x3b04=function(_0x1deb03,_0xd05ad8){_0x1deb03=_0x1deb03-0x0;var _0x189fe7=_0xb043[_0x1deb03];return _0x189fe7;};'use strict';var _=require('lodash');var util=require(_0x3b04('0x0'));var moment=require(_0x3b04('0x1'));var BPromise=require(_0x3b04('0x2'));var rs=require(_0x3b04('0x3'));var fs=require('fs');var Redis=require(_0x3b04('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x3b04('0x5'));var logger=require(_0x3b04('0x6'))(_0x3b04('0x7'));var config=require(_0x3b04('0x8'));var jayson=require(_0x3b04('0x9'));var client=jayson[_0x3b04('0xa')][_0x3b04('0xb')]({'port':0x232a});config[_0x3b04('0xc')]=_['defaults'](config[_0x3b04('0xc')],{'host':_0x3b04('0xd'),'port':0x18eb});var socket=require(_0x3b04('0xe'))(new Redis(config['redis']));require(_0x3b04('0xf'))['register'](socket);function respondWithRpcPromise(_0x2ed95e,_0xcc32c3,_0x2e9dd2){return new BPromise(function(_0x2f4003,_0x1c3706){return client[_0x3b04('0x10')](_0x2ed95e,_0x2e9dd2)['then'](function(_0x1f5ed9){logger[_0x3b04('0x11')]('FaxInteraction,\x20%s,\x20%s',_0xcc32c3,_0x3b04('0x12'));logger[_0x3b04('0x13')](_0x3b04('0x14'),_0xcc32c3,_0x3b04('0x12'),JSON['stringify'](_0x1f5ed9));if(_0x1f5ed9[_0x3b04('0x15')]){if(_0x1f5ed9[_0x3b04('0x15')][_0x3b04('0x16')]===0x1f4){logger['error'](_0x3b04('0x17'),_0xcc32c3,_0x1f5ed9[_0x3b04('0x15')][_0x3b04('0x18')]);return _0x1c3706(_0x1f5ed9[_0x3b04('0x15')][_0x3b04('0x18')]);}logger[_0x3b04('0x15')]('FaxInteraction,\x20%s,\x20%s',_0xcc32c3,_0x1f5ed9[_0x3b04('0x15')][_0x3b04('0x18')]);return _0x2f4003(_0x1f5ed9['error'][_0x3b04('0x18')]);}else{logger[_0x3b04('0x11')](_0x3b04('0x17'),_0xcc32c3,'request\x20sent');_0x2f4003(_0x1f5ed9[_0x3b04('0x19')]['message']);}})[_0x3b04('0x1a')](function(_0x581b8d){logger[_0x3b04('0x15')]('FaxInteraction,\x20%s,\x20%s',_0xcc32c3,_0x581b8d);_0x1c3706(_0x581b8d);});});}exports[_0x3b04('0x1b')]=function(_0x1b8ae4){var _0x469a06=this;return new Promise(function(_0x405d2a,_0x5f044e){return db['FaxInteraction'][_0x3b04('0x1c')](_0x1b8ae4['body'],{'raw':_0x1b8ae4[_0x3b04('0x1d')]?_0x1b8ae4[_0x3b04('0x1d')][_0x3b04('0x1e')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x1b8ae4[_0x3b04('0x1d')]?_0x1b8ae4['options'][_0x3b04('0x1f')]||null:null,'attributes':_0x1b8ae4[_0x3b04('0x1d')]?_0x1b8ae4[_0x3b04('0x1d')][_0x3b04('0x20')]||null:null,'limit':_0x1b8ae4[_0x3b04('0x1d')]?_0x1b8ae4[_0x3b04('0x1d')]['limit']||null:null})[_0x3b04('0x21')](function(_0x2ffc0f){logger[_0x3b04('0x11')](_0x3b04('0x1b'),_0x1b8ae4);logger[_0x3b04('0x13')](_0x3b04('0x1b'),_0x1b8ae4,JSON['stringify'](_0x2ffc0f));_0x405d2a(_0x2ffc0f);})[_0x3b04('0x1a')](function(_0x457b0b){logger['error'](_0x3b04('0x1b'),_0x457b0b[_0x3b04('0x18')],_0x1b8ae4);_0x5f044e(_0x469a06[_0x3b04('0x15')](0x1f4,_0x457b0b[_0x3b04('0x18')]));});});};exports[_0x3b04('0x22')]=function(_0x1c1d74){return new Promise(function(_0x398ea8,_0x1b7c08){return db['FaxInteraction'][_0x3b04('0x23')]({'where':_0x1c1d74['options']?_0x1c1d74[_0x3b04('0x1d')][_0x3b04('0x1f')]||null:null})['then'](function(_0x3e8c1a){if(_0x3e8c1a){return _0x3e8c1a[_0x3b04('0x24')](_0x1c1d74[_0x3b04('0x25')][_0x3b04('0x26')],_[_0x3b04('0x27')](_0x1c1d74[_0x3b04('0x25')],[_0x3b04('0x26'),'id'])||{});}})[_0x3b04('0x28')](function(_0xf76fb8){logger['info'](_0x3b04('0x29'),_0x1c1d74);logger[_0x3b04('0x13')](_0x3b04('0x29'),_0x1c1d74,JSON[_0x3b04('0x2a')](_0xf76fb8));_0x398ea8(_0xf76fb8);})[_0x3b04('0x1a')](function(_0x1e7b4b){logger[_0x3b04('0x15')]('AddTags',_0x1e7b4b[_0x3b04('0x18')],_0x1c1d74);_0x1b7c08(_this[_0x3b04('0x15')](0x1f4,_0x1e7b4b[_0x3b04('0x18')]));});});};