aee3eb3e2801acb35dffa08a524bf302748c08a0
[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 _0xbbf5=['lodash','util','moment','bluebird','../../mysqldb','../../config/logger','../../config/environment','jayson/promise','client','redis','defaults','localhost','socket.io-emitter','./faxInteraction.socket','then','FaxInteraction,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','info','result','catch','UpdateFaxInteraction','FaxInteraction','body','options','raw','where','attributes','AddTagsToFaxInteraction','find','addTags','ids','omit','spread','AddTags'];(function(_0x58b0c0,_0x3be59d){var _0x34ca9d=function(_0x5d4f21){while(--_0x5d4f21){_0x58b0c0['push'](_0x58b0c0['shift']());}};_0x34ca9d(++_0x3be59d);}(_0xbbf5,0xe4));var _0x5bbf=function(_0x16b5cc,_0x19cac5){_0x16b5cc=_0x16b5cc-0x0;var _0x2ca476=_0xbbf5[_0x16b5cc];return _0x2ca476;};'use strict';var _=require(_0x5bbf('0x0'));var util=require(_0x5bbf('0x1'));var moment=require(_0x5bbf('0x2'));var BPromise=require(_0x5bbf('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x5bbf('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0x5bbf('0x5'))('rpc');var config=require(_0x5bbf('0x6'));var jayson=require(_0x5bbf('0x7'));var client=jayson[_0x5bbf('0x8')]['http']({'port':0x232a});config[_0x5bbf('0x9')]=_[_0x5bbf('0xa')](config[_0x5bbf('0x9')],{'host':_0x5bbf('0xb'),'port':0x18eb});var socket=require(_0x5bbf('0xc'))(new Redis(config['redis']));require(_0x5bbf('0xd'))['register'](socket);function respondWithRpcPromise(_0x3dda53,_0x194c77,_0x211d4d){return new BPromise(function(_0x55f9c5,_0x450f19){return client['request'](_0x3dda53,_0x211d4d)[_0x5bbf('0xe')](function(_0x868f1e){logger['info'](_0x5bbf('0xf'),_0x194c77,_0x5bbf('0x10'));logger[_0x5bbf('0x11')]('FaxInteraction,\x20%s,\x20%s,\x20%s',_0x194c77,_0x5bbf('0x10'),JSON[_0x5bbf('0x12')](_0x868f1e));if(_0x868f1e['error']){if(_0x868f1e['error']['code']===0x1f4){logger[_0x5bbf('0x13')](_0x5bbf('0xf'),_0x194c77,_0x868f1e['error'][_0x5bbf('0x14')]);return _0x450f19(_0x868f1e[_0x5bbf('0x13')][_0x5bbf('0x14')]);}logger[_0x5bbf('0x13')]('FaxInteraction,\x20%s,\x20%s',_0x194c77,_0x868f1e[_0x5bbf('0x13')][_0x5bbf('0x14')]);return _0x55f9c5(_0x868f1e[_0x5bbf('0x13')][_0x5bbf('0x14')]);}else{logger[_0x5bbf('0x15')]('FaxInteraction,\x20%s,\x20%s',_0x194c77,_0x5bbf('0x10'));_0x55f9c5(_0x868f1e[_0x5bbf('0x16')][_0x5bbf('0x14')]);}})[_0x5bbf('0x17')](function(_0x562bc9){logger[_0x5bbf('0x13')](_0x5bbf('0xf'),_0x194c77,_0x562bc9);_0x450f19(_0x562bc9);});});}exports[_0x5bbf('0x18')]=function(_0x402ae3){var _0x44294f=this;return new Promise(function(_0x55af17,_0x344592){return db[_0x5bbf('0x19')]['update'](_0x402ae3[_0x5bbf('0x1a')],{'raw':_0x402ae3[_0x5bbf('0x1b')]?_0x402ae3[_0x5bbf('0x1b')][_0x5bbf('0x1c')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x402ae3[_0x5bbf('0x1b')]?_0x402ae3[_0x5bbf('0x1b')][_0x5bbf('0x1d')]||null:null,'attributes':_0x402ae3[_0x5bbf('0x1b')]?_0x402ae3[_0x5bbf('0x1b')][_0x5bbf('0x1e')]||null:null,'limit':_0x402ae3[_0x5bbf('0x1b')]?_0x402ae3[_0x5bbf('0x1b')]['limit']||null:null})[_0x5bbf('0xe')](function(_0x293f38){logger[_0x5bbf('0x15')](_0x5bbf('0x18'),_0x402ae3);logger['debug'](_0x5bbf('0x18'),_0x402ae3,JSON['stringify'](_0x293f38));_0x55af17(_0x293f38);})[_0x5bbf('0x17')](function(_0x3b6466){logger['error'](_0x5bbf('0x18'),_0x3b6466[_0x5bbf('0x14')],_0x402ae3);_0x344592(_0x44294f[_0x5bbf('0x13')](0x1f4,_0x3b6466[_0x5bbf('0x14')]));});});};exports[_0x5bbf('0x1f')]=function(_0x21212a){return new Promise(function(_0x2cda84,_0x3d9e49){return db[_0x5bbf('0x19')][_0x5bbf('0x20')]({'where':_0x21212a[_0x5bbf('0x1b')]?_0x21212a[_0x5bbf('0x1b')][_0x5bbf('0x1d')]||null:null})['then'](function(_0x168a2b){if(_0x168a2b){return _0x168a2b[_0x5bbf('0x21')](_0x21212a[_0x5bbf('0x1a')][_0x5bbf('0x22')],_[_0x5bbf('0x23')](_0x21212a['body'],[_0x5bbf('0x22'),'id'])||{});}})[_0x5bbf('0x24')](function(_0x2c7444){logger[_0x5bbf('0x15')](_0x5bbf('0x25'),_0x21212a);logger[_0x5bbf('0x11')](_0x5bbf('0x25'),_0x21212a,JSON[_0x5bbf('0x12')](_0x2c7444));_0x2cda84(_0x2c7444);})[_0x5bbf('0x17')](function(_0x39ca81){logger['error'](_0x5bbf('0x25'),_0x39ca81[_0x5bbf('0x14')],_0x21212a);_0x3d9e49(_this[_0x5bbf('0x13')](0x1f4,_0x39ca81[_0x5bbf('0x14')]));});});};