Built motion from commit c738b9ac.|2.6.25
[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 _0x2616=['then','info','request\x20sent','debug','stringify','error','code','message','FaxInteraction,\x20%s,\x20%s','result','catch','UpdateFaxInteraction','update','body','options','raw','where','attributes','limit','FaxInteraction','addTags','ids','AddTags','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','http','redis','defaults','register','request'];(function(_0x3b86ab,_0x2bbb75){var _0x575d84=function(_0x324cef){while(--_0x324cef){_0x3b86ab['push'](_0x3b86ab['shift']());}};_0x575d84(++_0x2bbb75);}(_0x2616,0xb3));var _0x6261=function(_0x119705,_0xba9427){_0x119705=_0x119705-0x0;var _0x2affc2=_0x2616[_0x119705];return _0x2affc2;};'use strict';var _=require(_0x6261('0x0'));var util=require(_0x6261('0x1'));var moment=require(_0x6261('0x2'));var BPromise=require(_0x6261('0x3'));var rs=require(_0x6261('0x4'));var fs=require('fs');var Redis=require(_0x6261('0x5'));var db=require(_0x6261('0x6'))['db'];var utils=require(_0x6261('0x7'));var logger=require(_0x6261('0x8'))(_0x6261('0x9'));var config=require('../../config/environment');var jayson=require(_0x6261('0xa'));var client=jayson['client'][_0x6261('0xb')]({'port':0x232a});config[_0x6261('0xc')]=_[_0x6261('0xd')](config[_0x6261('0xc')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x6261('0xc')]));require('./faxInteraction.socket')[_0x6261('0xe')](socket);function respondWithRpcPromise(_0x4583db,_0x2c352c,_0x5e5272){return new BPromise(function(_0x247efc,_0x1ba22a){return client[_0x6261('0xf')](_0x4583db,_0x5e5272)[_0x6261('0x10')](function(_0x8c1612){logger[_0x6261('0x11')]('FaxInteraction,\x20%s,\x20%s',_0x2c352c,_0x6261('0x12'));logger[_0x6261('0x13')]('FaxInteraction,\x20%s,\x20%s,\x20%s',_0x2c352c,_0x6261('0x12'),JSON[_0x6261('0x14')](_0x8c1612));if(_0x8c1612[_0x6261('0x15')]){if(_0x8c1612[_0x6261('0x15')][_0x6261('0x16')]===0x1f4){logger['error']('FaxInteraction,\x20%s,\x20%s',_0x2c352c,_0x8c1612[_0x6261('0x15')]['message']);return _0x1ba22a(_0x8c1612['error'][_0x6261('0x17')]);}logger[_0x6261('0x15')](_0x6261('0x18'),_0x2c352c,_0x8c1612['error']['message']);return _0x247efc(_0x8c1612['error'][_0x6261('0x17')]);}else{logger['info'](_0x6261('0x18'),_0x2c352c,_0x6261('0x12'));_0x247efc(_0x8c1612[_0x6261('0x19')][_0x6261('0x17')]);}})[_0x6261('0x1a')](function(_0x43e413){logger['error']('FaxInteraction,\x20%s,\x20%s',_0x2c352c,_0x43e413);_0x1ba22a(_0x43e413);});});}exports[_0x6261('0x1b')]=function(_0x2af4d6){var _0x3f88df=this;return new Promise(function(_0x2c94e8,_0x3ea94c){return db['FaxInteraction'][_0x6261('0x1c')](_0x2af4d6[_0x6261('0x1d')],{'raw':_0x2af4d6[_0x6261('0x1e')]?_0x2af4d6[_0x6261('0x1e')][_0x6261('0x1f')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x2af4d6['options']?_0x2af4d6[_0x6261('0x1e')][_0x6261('0x20')]||null:null,'attributes':_0x2af4d6[_0x6261('0x1e')]?_0x2af4d6[_0x6261('0x1e')][_0x6261('0x21')]||null:null,'limit':_0x2af4d6[_0x6261('0x1e')]?_0x2af4d6[_0x6261('0x1e')][_0x6261('0x22')]||null:null})['then'](function(_0x9bfdba){logger[_0x6261('0x11')](_0x6261('0x1b'),_0x2af4d6);logger[_0x6261('0x13')](_0x6261('0x1b'),_0x2af4d6,JSON['stringify'](_0x9bfdba));_0x2c94e8(_0x9bfdba);})['catch'](function(_0x4a7d6a){logger[_0x6261('0x15')](_0x6261('0x1b'),_0x4a7d6a['message'],_0x2af4d6);_0x3ea94c(_0x3f88df[_0x6261('0x15')](0x1f4,_0x4a7d6a['message']));});});};exports['AddTagsToFaxInteraction']=function(_0x238548){return new Promise(function(_0x10796d,_0x51b7be){return db[_0x6261('0x23')]['find']({'where':_0x238548[_0x6261('0x1e')]?_0x238548['options'][_0x6261('0x20')]||null:null})[_0x6261('0x10')](function(_0x3807a2){if(_0x3807a2){return _0x3807a2[_0x6261('0x24')](_0x238548[_0x6261('0x1d')]['ids'],_['omit'](_0x238548['body'],[_0x6261('0x25'),'id'])||{});}})['spread'](function(_0x131021){logger[_0x6261('0x11')](_0x6261('0x26'),_0x238548);logger[_0x6261('0x13')](_0x6261('0x26'),_0x238548,JSON[_0x6261('0x14')](_0x131021));_0x10796d(_0x131021);})[_0x6261('0x1a')](function(_0x2261bf){logger['error'](_0x6261('0x26'),_0x2261bf[_0x6261('0x17')],_0x238548);_0x51b7be(_this[_0x6261('0x15')](0x1f4,_0x2261bf[_0x6261('0x17')]));});});};