Built motion from commit d6d69adf.|2.6.33
[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 _0x76cc=['result','catch','UpdateFaxInteraction','FaxInteraction','update','body','options','raw','where','attributes','limit','find','then','ids','omit','spread','AddTags','lodash','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/environment','jayson/promise','client','http','redis','localhost','socket.io-emitter','./faxInteraction.socket','register','request\x20sent','debug','FaxInteraction,\x20%s,\x20%s,\x20%s','stringify','error','code','FaxInteraction,\x20%s,\x20%s','message','info'];(function(_0x35e33c,_0x16dd60){var _0x2f854c=function(_0x71410f){while(--_0x71410f){_0x35e33c['push'](_0x35e33c['shift']());}};_0x2f854c(++_0x16dd60);}(_0x76cc,0x130));var _0xc76c=function(_0x5794db,_0x2ee0d4){_0x5794db=_0x5794db-0x0;var _0x1dbfd6=_0x76cc[_0x5794db];return _0x1dbfd6;};'use strict';var _=require(_0xc76c('0x0'));var util=require('util');var moment=require(_0xc76c('0x1'));var BPromise=require('bluebird');var rs=require(_0xc76c('0x2'));var fs=require('fs');var Redis=require(_0xc76c('0x3'));var db=require(_0xc76c('0x4'))['db'];var utils=require(_0xc76c('0x5'));var logger=require('../../config/logger')('rpc');var config=require(_0xc76c('0x6'));var jayson=require(_0xc76c('0x7'));var client=jayson[_0xc76c('0x8')][_0xc76c('0x9')]({'port':0x232a});config[_0xc76c('0xa')]=_['defaults'](config['redis'],{'host':_0xc76c('0xb'),'port':0x18eb});var socket=require(_0xc76c('0xc'))(new Redis(config[_0xc76c('0xa')]));require(_0xc76c('0xd'))[_0xc76c('0xe')](socket);function respondWithRpcPromise(_0x1bce86,_0x120c68,_0x3c65d4){return new BPromise(function(_0x3a395f,_0x185c8e){return client['request'](_0x1bce86,_0x3c65d4)['then'](function(_0x3fde55){logger['info']('FaxInteraction,\x20%s,\x20%s',_0x120c68,_0xc76c('0xf'));logger[_0xc76c('0x10')](_0xc76c('0x11'),_0x120c68,_0xc76c('0xf'),JSON[_0xc76c('0x12')](_0x3fde55));if(_0x3fde55[_0xc76c('0x13')]){if(_0x3fde55[_0xc76c('0x13')][_0xc76c('0x14')]===0x1f4){logger[_0xc76c('0x13')](_0xc76c('0x15'),_0x120c68,_0x3fde55[_0xc76c('0x13')][_0xc76c('0x16')]);return _0x185c8e(_0x3fde55[_0xc76c('0x13')]['message']);}logger[_0xc76c('0x13')](_0xc76c('0x15'),_0x120c68,_0x3fde55['error']['message']);return _0x3a395f(_0x3fde55[_0xc76c('0x13')][_0xc76c('0x16')]);}else{logger[_0xc76c('0x17')](_0xc76c('0x15'),_0x120c68,_0xc76c('0xf'));_0x3a395f(_0x3fde55[_0xc76c('0x18')]['message']);}})[_0xc76c('0x19')](function(_0x1177f3){logger[_0xc76c('0x13')](_0xc76c('0x15'),_0x120c68,_0x1177f3);_0x185c8e(_0x1177f3);});});}exports[_0xc76c('0x1a')]=function(_0x34c031){var _0x4b8c9c=this;return new Promise(function(_0x47f55f,_0x349abb){return db[_0xc76c('0x1b')][_0xc76c('0x1c')](_0x34c031[_0xc76c('0x1d')],{'raw':_0x34c031[_0xc76c('0x1e')]?_0x34c031['options'][_0xc76c('0x1f')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x34c031[_0xc76c('0x1e')]?_0x34c031[_0xc76c('0x1e')][_0xc76c('0x20')]||null:null,'attributes':_0x34c031[_0xc76c('0x1e')]?_0x34c031[_0xc76c('0x1e')][_0xc76c('0x21')]||null:null,'limit':_0x34c031['options']?_0x34c031['options'][_0xc76c('0x22')]||null:null})['then'](function(_0x5e5ccf){logger[_0xc76c('0x17')](_0xc76c('0x1a'),_0x34c031);logger[_0xc76c('0x10')](_0xc76c('0x1a'),_0x34c031,JSON[_0xc76c('0x12')](_0x5e5ccf));_0x47f55f(_0x5e5ccf);})[_0xc76c('0x19')](function(_0x5c27cf){logger[_0xc76c('0x13')](_0xc76c('0x1a'),_0x5c27cf[_0xc76c('0x16')],_0x34c031);_0x349abb(_0x4b8c9c[_0xc76c('0x13')](0x1f4,_0x5c27cf['message']));});});};exports['AddTagsToFaxInteraction']=function(_0x102ab4){return new Promise(function(_0x26fce0,_0x665f37){return db[_0xc76c('0x1b')][_0xc76c('0x23')]({'where':_0x102ab4[_0xc76c('0x1e')]?_0x102ab4[_0xc76c('0x1e')][_0xc76c('0x20')]||null:null})[_0xc76c('0x24')](function(_0x34d3b2){if(_0x34d3b2){return _0x34d3b2['addTags'](_0x102ab4[_0xc76c('0x1d')][_0xc76c('0x25')],_[_0xc76c('0x26')](_0x102ab4[_0xc76c('0x1d')],[_0xc76c('0x25'),'id'])||{});}})[_0xc76c('0x27')](function(_0x2a629d){logger[_0xc76c('0x17')](_0xc76c('0x28'),_0x102ab4);logger[_0xc76c('0x10')](_0xc76c('0x28'),_0x102ab4,JSON[_0xc76c('0x12')](_0x2a629d));_0x26fce0(_0x2a629d);})[_0xc76c('0x19')](function(_0xc4f208){logger[_0xc76c('0x13')](_0xc76c('0x28'),_0xc4f208[_0xc76c('0x16')],_0x102ab4);_0x665f37(_this[_0xc76c('0x13')](0x1f4,_0xc4f208[_0xc76c('0x16')]));});});};