Built motion from commit 47436d59.|2.6.7
[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 _0x8103=['http','defaults','redis','localhost','./faxInteraction.socket','register','then','info','FaxInteraction,\x20%s,\x20%s','request\x20sent','debug','FaxInteraction,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','UpdateFaxInteraction','FaxInteraction','update','body','options','raw','where','limit','find','addTags','ids','AddTags','lodash','util','bluebird','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client'];(function(_0x1d24eb,_0x12295b){var _0x1dc576=function(_0x4d5770){while(--_0x4d5770){_0x1d24eb['push'](_0x1d24eb['shift']());}};_0x1dc576(++_0x12295b);}(_0x8103,0x12f));var _0x3810=function(_0x3b406a,_0x2c2761){_0x3b406a=_0x3b406a-0x0;var _0x3346c9=_0x8103[_0x3b406a];return _0x3346c9;};'use strict';var _=require(_0x3810('0x0'));var util=require(_0x3810('0x1'));var moment=require('moment');var BPromise=require(_0x3810('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x3810('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0x3810('0x4'))(_0x3810('0x5'));var config=require(_0x3810('0x6'));var jayson=require(_0x3810('0x7'));var client=jayson[_0x3810('0x8')][_0x3810('0x9')]({'port':0x232a});config['redis']=_[_0x3810('0xa')](config[_0x3810('0xb')],{'host':_0x3810('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x3810('0xb')]));require(_0x3810('0xd'))[_0x3810('0xe')](socket);function respondWithRpcPromise(_0x14c839,_0x306211,_0x512824){return new BPromise(function(_0x17ea21,_0xd40bc4){return client['request'](_0x14c839,_0x512824)[_0x3810('0xf')](function(_0x3f3c0e){logger[_0x3810('0x10')](_0x3810('0x11'),_0x306211,_0x3810('0x12'));logger[_0x3810('0x13')](_0x3810('0x14'),_0x306211,'request\x20sent',JSON[_0x3810('0x15')](_0x3f3c0e));if(_0x3f3c0e[_0x3810('0x16')]){if(_0x3f3c0e[_0x3810('0x16')][_0x3810('0x17')]===0x1f4){logger['error'](_0x3810('0x11'),_0x306211,_0x3f3c0e['error']['message']);return _0xd40bc4(_0x3f3c0e['error'][_0x3810('0x18')]);}logger[_0x3810('0x16')](_0x3810('0x11'),_0x306211,_0x3f3c0e['error'][_0x3810('0x18')]);return _0x17ea21(_0x3f3c0e[_0x3810('0x16')][_0x3810('0x18')]);}else{logger['info'](_0x3810('0x11'),_0x306211,_0x3810('0x12'));_0x17ea21(_0x3f3c0e[_0x3810('0x19')]['message']);}})[_0x3810('0x1a')](function(_0x2fb4eb){logger[_0x3810('0x16')](_0x3810('0x11'),_0x306211,_0x2fb4eb);_0xd40bc4(_0x2fb4eb);});});}exports[_0x3810('0x1b')]=function(_0x389627){var _0x2fa513=this;return new Promise(function(_0x1495e0,_0x4c0214){return db[_0x3810('0x1c')][_0x3810('0x1d')](_0x389627[_0x3810('0x1e')],{'raw':_0x389627['options']?_0x389627[_0x3810('0x1f')][_0x3810('0x20')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x389627[_0x3810('0x1f')]?_0x389627['options'][_0x3810('0x21')]||null:null,'attributes':_0x389627[_0x3810('0x1f')]?_0x389627[_0x3810('0x1f')]['attributes']||null:null,'limit':_0x389627[_0x3810('0x1f')]?_0x389627[_0x3810('0x1f')][_0x3810('0x22')]||null:null})[_0x3810('0xf')](function(_0x4d5d4e){logger[_0x3810('0x10')](_0x3810('0x1b'),_0x389627);logger[_0x3810('0x13')]('UpdateFaxInteraction',_0x389627,JSON[_0x3810('0x15')](_0x4d5d4e));_0x1495e0(_0x4d5d4e);})[_0x3810('0x1a')](function(_0x3d0544){logger[_0x3810('0x16')]('UpdateFaxInteraction',_0x3d0544[_0x3810('0x18')],_0x389627);_0x4c0214(_0x2fa513[_0x3810('0x16')](0x1f4,_0x3d0544[_0x3810('0x18')]));});});};exports['AddTagsToFaxInteraction']=function(_0x180690){return new Promise(function(_0x2f40b2,_0x481c60){return db[_0x3810('0x1c')][_0x3810('0x23')]({'where':_0x180690[_0x3810('0x1f')]?_0x180690[_0x3810('0x1f')][_0x3810('0x21')]||null:null})[_0x3810('0xf')](function(_0x5609b8){if(_0x5609b8){return _0x5609b8[_0x3810('0x24')](_0x180690[_0x3810('0x1e')][_0x3810('0x25')],_['omit'](_0x180690[_0x3810('0x1e')],[_0x3810('0x25'),'id'])||{});}})['spread'](function(_0x347a3a){logger[_0x3810('0x10')](_0x3810('0x26'),_0x180690);logger[_0x3810('0x13')](_0x3810('0x26'),_0x180690,JSON[_0x3810('0x15')](_0x347a3a));_0x2f40b2(_0x347a3a);})[_0x3810('0x1a')](function(_0x4668ac){logger['error'](_0x3810('0x26'),_0x4668ac[_0x3810('0x18')],_0x180690);_0x481c60(_this[_0x3810('0x16')](0x1f4,_0x4668ac['message']));});});};