b411e6775dc798534dcec5326aa506ac06fdc62d
[motion2.git] / server / api / faxMessage / faxMessage.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 _0xc072=['create','body','options','raw','then','debug','UpdateFaxMessage','where','attributes','stringify','moment','bluebird','randomstring','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','http','defaults','redis','socket.io-emitter','./faxMessage.socket','register','request','FaxMessage,\x20%s,\x20%s','request\x20sent','FaxMessage,\x20%s,\x20%s,\x20%s','code','error','message','info','result','catch','CreateFaxMessage','FaxMessage'];(function(_0x27652d,_0x3ac593){var _0x1f00b4=function(_0x10f1c3){while(--_0x10f1c3){_0x27652d['push'](_0x27652d['shift']());}};_0x1f00b4(++_0x3ac593);}(_0xc072,0x14e));var _0x2c07=function(_0x2a7e6c,_0x183281){_0x2a7e6c=_0x2a7e6c-0x0;var _0x11926b=_0xc072[_0x2a7e6c];return _0x11926b;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x2c07('0x0'));var BPromise=require(_0x2c07('0x1'));var rs=require(_0x2c07('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x2c07('0x3'))['db'];var utils=require(_0x2c07('0x4'));var logger=require('../../config/logger')(_0x2c07('0x5'));var config=require(_0x2c07('0x6'));var jayson=require(_0x2c07('0x7'));var client=jayson['client'][_0x2c07('0x8')]({'port':0x232a});config['redis']=_[_0x2c07('0x9')](config[_0x2c07('0xa')],{'host':'localhost','port':0x18eb});var socket=require(_0x2c07('0xb'))(new Redis(config['redis']));require(_0x2c07('0xc'))[_0x2c07('0xd')](socket);function respondWithRpcPromise(_0x329114,_0x15825d,_0x3dd395){return new BPromise(function(_0x3e7fca,_0x562a7e){return client[_0x2c07('0xe')](_0x329114,_0x3dd395)['then'](function(_0x511e59){logger['info'](_0x2c07('0xf'),_0x15825d,_0x2c07('0x10'));logger['debug'](_0x2c07('0x11'),_0x15825d,_0x2c07('0x10'),JSON['stringify'](_0x511e59));if(_0x511e59['error']){if(_0x511e59['error'][_0x2c07('0x12')]===0x1f4){logger['error'](_0x2c07('0xf'),_0x15825d,_0x511e59[_0x2c07('0x13')][_0x2c07('0x14')]);return _0x562a7e(_0x511e59[_0x2c07('0x13')][_0x2c07('0x14')]);}logger[_0x2c07('0x13')](_0x2c07('0xf'),_0x15825d,_0x511e59[_0x2c07('0x13')][_0x2c07('0x14')]);return _0x3e7fca(_0x511e59[_0x2c07('0x13')][_0x2c07('0x14')]);}else{logger[_0x2c07('0x15')](_0x2c07('0xf'),_0x15825d,_0x2c07('0x10'));_0x3e7fca(_0x511e59[_0x2c07('0x16')]['message']);}})[_0x2c07('0x17')](function(_0x387e5f){logger[_0x2c07('0x13')](_0x2c07('0xf'),_0x15825d,_0x387e5f);_0x562a7e(_0x387e5f);});});}exports[_0x2c07('0x18')]=function(_0x136e00){var _0x30986a=this;return new Promise(function(_0x553549,_0xe01103){return db[_0x2c07('0x19')][_0x2c07('0x1a')](_0x136e00[_0x2c07('0x1b')],{'raw':_0x136e00[_0x2c07('0x1c')]?_0x136e00[_0x2c07('0x1c')][_0x2c07('0x1d')]===undefined?!![]:![]:!![]})[_0x2c07('0x1e')](function(_0x529307){logger[_0x2c07('0x15')](_0x2c07('0x18'),_0x136e00);logger[_0x2c07('0x1f')]('CreateFaxMessage',_0x136e00,JSON['stringify'](_0x529307));_0x553549(_0x529307);})['catch'](function(_0x2efe01){logger[_0x2c07('0x13')](_0x2c07('0x18'),_0x2efe01[_0x2c07('0x14')],_0x136e00);_0xe01103(_0x30986a[_0x2c07('0x13')](0x1f4,_0x2efe01[_0x2c07('0x14')]));});});};exports[_0x2c07('0x20')]=function(_0xa27172){var _0x184863=this;return new Promise(function(_0x53460a,_0x1d2f77){return db[_0x2c07('0x19')]['update'](_0xa27172[_0x2c07('0x1b')],{'raw':_0xa27172[_0x2c07('0x1c')]?_0xa27172[_0x2c07('0x1c')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0xa27172[_0x2c07('0x1c')]?_0xa27172[_0x2c07('0x1c')][_0x2c07('0x21')]||null:null,'attributes':_0xa27172[_0x2c07('0x1c')]?_0xa27172[_0x2c07('0x1c')][_0x2c07('0x22')]||null:null,'limit':_0xa27172['options']?_0xa27172[_0x2c07('0x1c')]['limit']||null:null})[_0x2c07('0x1e')](function(_0xbcdbe3){logger[_0x2c07('0x15')](_0x2c07('0x20'),_0xa27172);logger[_0x2c07('0x1f')]('UpdateFaxMessage',_0xa27172,JSON[_0x2c07('0x23')](_0xbcdbe3));_0x53460a(_0xbcdbe3);})[_0x2c07('0x17')](function(_0x1324fb){logger[_0x2c07('0x13')](_0x2c07('0x20'),_0x1324fb[_0x2c07('0x14')],_0xa27172);_0x1d2f77(_0x184863['error'](0x1f4,_0x1324fb[_0x2c07('0x14')]));});});};