Built motion from commit 3c2ce842.|2.6.31
[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 _0x7273=['where','attributes','limit','find','ids','omit','spread','AddTags','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','then','FaxInteraction,\x20%s,\x20%s','request\x20sent','debug','FaxInteraction,\x20%s,\x20%s,\x20%s','stringify','code','error','message','info','catch','UpdateFaxInteraction','FaxInteraction','body','options','raw'];(function(_0x53b1d6,_0xbe6d6c){var _0x9eb530=function(_0x22e83b){while(--_0x22e83b){_0x53b1d6['push'](_0x53b1d6['shift']());}};_0x9eb530(++_0xbe6d6c);}(_0x7273,0x10b));var _0x3727=function(_0x31ca88,_0x418a2f){_0x31ca88=_0x31ca88-0x0;var _0x2760c6=_0x7273[_0x31ca88];return _0x2760c6;};'use strict';var _=require('lodash');var util=require(_0x3727('0x0'));var moment=require(_0x3727('0x1'));var BPromise=require('bluebird');var rs=require(_0x3727('0x2'));var fs=require('fs');var Redis=require(_0x3727('0x3'));var db=require(_0x3727('0x4'))['db'];var utils=require(_0x3727('0x5'));var logger=require('../../config/logger')(_0x3727('0x6'));var config=require(_0x3727('0x7'));var jayson=require(_0x3727('0x8'));var client=jayson[_0x3727('0x9')][_0x3727('0xa')]({'port':0x232a});config[_0x3727('0xb')]=_[_0x3727('0xc')](config[_0x3727('0xb')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x3727('0xb')]));require('./faxInteraction.socket')['register'](socket);function respondWithRpcPromise(_0x55ac7e,_0x11c0b8,_0x33af26){return new BPromise(function(_0x589af3,_0x1ea796){return client['request'](_0x55ac7e,_0x33af26)[_0x3727('0xd')](function(_0x8ce3ed){logger['info'](_0x3727('0xe'),_0x11c0b8,_0x3727('0xf'));logger[_0x3727('0x10')](_0x3727('0x11'),_0x11c0b8,'request\x20sent',JSON[_0x3727('0x12')](_0x8ce3ed));if(_0x8ce3ed['error']){if(_0x8ce3ed['error'][_0x3727('0x13')]===0x1f4){logger[_0x3727('0x14')](_0x3727('0xe'),_0x11c0b8,_0x8ce3ed[_0x3727('0x14')][_0x3727('0x15')]);return _0x1ea796(_0x8ce3ed['error'][_0x3727('0x15')]);}logger[_0x3727('0x14')](_0x3727('0xe'),_0x11c0b8,_0x8ce3ed['error'][_0x3727('0x15')]);return _0x589af3(_0x8ce3ed[_0x3727('0x14')][_0x3727('0x15')]);}else{logger[_0x3727('0x16')](_0x3727('0xe'),_0x11c0b8,_0x3727('0xf'));_0x589af3(_0x8ce3ed['result'][_0x3727('0x15')]);}})[_0x3727('0x17')](function(_0x20bd63){logger['error'](_0x3727('0xe'),_0x11c0b8,_0x20bd63);_0x1ea796(_0x20bd63);});});}exports[_0x3727('0x18')]=function(_0x64d73){var _0x1f72a7=this;return new Promise(function(_0x282166,_0x20ad1e){return db[_0x3727('0x19')]['update'](_0x64d73[_0x3727('0x1a')],{'raw':_0x64d73[_0x3727('0x1b')]?_0x64d73[_0x3727('0x1b')][_0x3727('0x1c')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x64d73[_0x3727('0x1b')]?_0x64d73[_0x3727('0x1b')][_0x3727('0x1d')]||null:null,'attributes':_0x64d73[_0x3727('0x1b')]?_0x64d73['options'][_0x3727('0x1e')]||null:null,'limit':_0x64d73[_0x3727('0x1b')]?_0x64d73[_0x3727('0x1b')][_0x3727('0x1f')]||null:null})[_0x3727('0xd')](function(_0x15b8fb){logger[_0x3727('0x16')](_0x3727('0x18'),_0x64d73);logger[_0x3727('0x10')](_0x3727('0x18'),_0x64d73,JSON['stringify'](_0x15b8fb));_0x282166(_0x15b8fb);})[_0x3727('0x17')](function(_0x31e3dc){logger['error'](_0x3727('0x18'),_0x31e3dc[_0x3727('0x15')],_0x64d73);_0x20ad1e(_0x1f72a7[_0x3727('0x14')](0x1f4,_0x31e3dc[_0x3727('0x15')]));});});};exports['AddTagsToFaxInteraction']=function(_0x4c9cf8){return new Promise(function(_0x594b06,_0x465ecd){return db[_0x3727('0x19')][_0x3727('0x20')]({'where':_0x4c9cf8['options']?_0x4c9cf8[_0x3727('0x1b')][_0x3727('0x1d')]||null:null})[_0x3727('0xd')](function(_0x2c302a){if(_0x2c302a){return _0x2c302a['addTags'](_0x4c9cf8[_0x3727('0x1a')][_0x3727('0x21')],_[_0x3727('0x22')](_0x4c9cf8['body'],['ids','id'])||{});}})[_0x3727('0x23')](function(_0xeb4a7d){logger['info'](_0x3727('0x24'),_0x4c9cf8);logger[_0x3727('0x10')](_0x3727('0x24'),_0x4c9cf8,JSON['stringify'](_0xeb4a7d));_0x594b06(_0xeb4a7d);})[_0x3727('0x17')](function(_0x2dcefd){logger['error'](_0x3727('0x24'),_0x2dcefd[_0x3727('0x15')],_0x4c9cf8);_0x465ecd(_this[_0x3727('0x14')](0x1f4,_0x2dcefd['message']));});});};