Built motion from commit (unavailable).|2.4.18
[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 _0x7cda=['then','catch','FaxMessage','body','raw','attributes','limit','UpdateFaxMessage','util','moment','bluebird','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','http','redis','socket.io-emitter','./faxMessage.socket','register','info','request\x20sent','debug','stringify','error','code','FaxMessage,\x20%s,\x20%s','message','result','CreateFaxMessage','create','options'];(function(_0x34f7d7,_0x5937a1){var _0x43cf70=function(_0xe133d6){while(--_0xe133d6){_0x34f7d7['push'](_0x34f7d7['shift']());}};_0x43cf70(++_0x5937a1);}(_0x7cda,0xf6));var _0xa7cd=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x7cda[_0x3dd15e];return _0x231fd0;};'use strict';var _=require('lodash');var util=require(_0xa7cd('0x0'));var moment=require(_0xa7cd('0x1'));var BPromise=require(_0xa7cd('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xa7cd('0x3'));var db=require(_0xa7cd('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0xa7cd('0x5'))(_0xa7cd('0x6'));var config=require(_0xa7cd('0x7'));var jayson=require(_0xa7cd('0x8'));var client=jayson['client'][_0xa7cd('0x9')]({'port':0x232a});config['redis']=_['defaults'](config[_0xa7cd('0xa')],{'host':'localhost','port':0x18eb});var socket=require(_0xa7cd('0xb'))(new Redis(config[_0xa7cd('0xa')]));require(_0xa7cd('0xc'))[_0xa7cd('0xd')](socket);function respondWithRpcPromise(_0x31879f,_0x372273,_0x39d8c4){return new BPromise(function(_0x1a66f7,_0xd20e5d){return client['request'](_0x31879f,_0x39d8c4)['then'](function(_0x3c38a4){logger[_0xa7cd('0xe')]('FaxMessage,\x20%s,\x20%s',_0x372273,_0xa7cd('0xf'));logger[_0xa7cd('0x10')]('FaxMessage,\x20%s,\x20%s,\x20%s',_0x372273,_0xa7cd('0xf'),JSON[_0xa7cd('0x11')](_0x3c38a4));if(_0x3c38a4[_0xa7cd('0x12')]){if(_0x3c38a4['error'][_0xa7cd('0x13')]===0x1f4){logger[_0xa7cd('0x12')](_0xa7cd('0x14'),_0x372273,_0x3c38a4[_0xa7cd('0x12')][_0xa7cd('0x15')]);return _0xd20e5d(_0x3c38a4[_0xa7cd('0x12')]['message']);}logger['error'](_0xa7cd('0x14'),_0x372273,_0x3c38a4[_0xa7cd('0x12')][_0xa7cd('0x15')]);return _0x1a66f7(_0x3c38a4['error'][_0xa7cd('0x15')]);}else{logger[_0xa7cd('0xe')]('FaxMessage,\x20%s,\x20%s',_0x372273,_0xa7cd('0xf'));_0x1a66f7(_0x3c38a4[_0xa7cd('0x16')][_0xa7cd('0x15')]);}})['catch'](function(_0x111774){logger[_0xa7cd('0x12')]('FaxMessage,\x20%s,\x20%s',_0x372273,_0x111774);_0xd20e5d(_0x111774);});});}exports[_0xa7cd('0x17')]=function(_0x7eab17){var _0x14305a=this;return new Promise(function(_0x5224b0,_0x4c601c){return db['FaxMessage'][_0xa7cd('0x18')](_0x7eab17['body'],{'raw':_0x7eab17['options']?_0x7eab17[_0xa7cd('0x19')]['raw']===undefined?!![]:![]:!![]})[_0xa7cd('0x1a')](function(_0x134612){logger['info']('CreateFaxMessage',_0x7eab17);logger['debug'](_0xa7cd('0x17'),_0x7eab17,JSON['stringify'](_0x134612));_0x5224b0(_0x134612);})[_0xa7cd('0x1b')](function(_0x1c79f9){logger['error'](_0xa7cd('0x17'),_0x1c79f9['message'],_0x7eab17);_0x4c601c(_0x14305a[_0xa7cd('0x12')](0x1f4,_0x1c79f9[_0xa7cd('0x15')]));});});};exports['UpdateFaxMessage']=function(_0x2796a5){var _0x4362a4=this;return new Promise(function(_0x53d3b7,_0x5ba778){return db[_0xa7cd('0x1c')]['update'](_0x2796a5[_0xa7cd('0x1d')],{'raw':_0x2796a5['options']?_0x2796a5[_0xa7cd('0x19')][_0xa7cd('0x1e')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x2796a5['options']?_0x2796a5['options']['where']||null:null,'attributes':_0x2796a5[_0xa7cd('0x19')]?_0x2796a5['options'][_0xa7cd('0x1f')]||null:null,'limit':_0x2796a5[_0xa7cd('0x19')]?_0x2796a5[_0xa7cd('0x19')][_0xa7cd('0x20')]||null:null})['then'](function(_0x11b7d7){logger['info'](_0xa7cd('0x21'),_0x2796a5);logger[_0xa7cd('0x10')]('UpdateFaxMessage',_0x2796a5,JSON[_0xa7cd('0x11')](_0x11b7d7));_0x53d3b7(_0x11b7d7);})[_0xa7cd('0x1b')](function(_0xb4cfa){logger[_0xa7cd('0x12')](_0xa7cd('0x21'),_0xb4cfa[_0xa7cd('0x15')],_0x2796a5);_0x5ba778(_0x4362a4[_0xa7cd('0x12')](0x1f4,_0xb4cfa[_0xa7cd('0x15')]));});});};