Built motion from commit (unavailable).|2.4.19
[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 _0x2a36=['redis','./faxMessage.socket','request','then','info','request\x20sent','FaxMessage,\x20%s,\x20%s,\x20%s','code','error','message','FaxMessage,\x20%s,\x20%s','result','FaxMessage','create','options','raw','CreateFaxMessage','stringify','catch','UpdateFaxMessage','update','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment'];(function(_0x26936d,_0x307dbf){var _0x318c38=function(_0x419d9e){while(--_0x419d9e){_0x26936d['push'](_0x26936d['shift']());}};_0x318c38(++_0x307dbf);}(_0x2a36,0x95));var _0x62a3=function(_0x5e7f4c,_0x4c36cb){_0x5e7f4c=_0x5e7f4c-0x0;var _0x33552e=_0x2a36[_0x5e7f4c];return _0x33552e;};'use strict';var _=require(_0x62a3('0x0'));var util=require(_0x62a3('0x1'));var moment=require(_0x62a3('0x2'));var BPromise=require(_0x62a3('0x3'));var rs=require(_0x62a3('0x4'));var fs=require('fs');var Redis=require(_0x62a3('0x5'));var db=require(_0x62a3('0x6'))['db'];var utils=require(_0x62a3('0x7'));var logger=require(_0x62a3('0x8'))(_0x62a3('0x9'));var config=require(_0x62a3('0xa'));var jayson=require('jayson/promise');var client=jayson['client']['http']({'port':0x232a});config[_0x62a3('0xb')]=_['defaults'](config[_0x62a3('0xb')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x62a3('0xb')]));require(_0x62a3('0xc'))['register'](socket);function respondWithRpcPromise(_0x3f8699,_0x406f49,_0x16ccfd){return new BPromise(function(_0x5146da,_0x1c8f84){return client[_0x62a3('0xd')](_0x3f8699,_0x16ccfd)[_0x62a3('0xe')](function(_0x3e20d9){logger[_0x62a3('0xf')]('FaxMessage,\x20%s,\x20%s',_0x406f49,_0x62a3('0x10'));logger['debug'](_0x62a3('0x11'),_0x406f49,_0x62a3('0x10'),JSON['stringify'](_0x3e20d9));if(_0x3e20d9['error']){if(_0x3e20d9['error'][_0x62a3('0x12')]===0x1f4){logger[_0x62a3('0x13')]('FaxMessage,\x20%s,\x20%s',_0x406f49,_0x3e20d9[_0x62a3('0x13')][_0x62a3('0x14')]);return _0x1c8f84(_0x3e20d9[_0x62a3('0x13')]['message']);}logger[_0x62a3('0x13')](_0x62a3('0x15'),_0x406f49,_0x3e20d9[_0x62a3('0x13')]['message']);return _0x5146da(_0x3e20d9[_0x62a3('0x13')][_0x62a3('0x14')]);}else{logger[_0x62a3('0xf')]('FaxMessage,\x20%s,\x20%s',_0x406f49,_0x62a3('0x10'));_0x5146da(_0x3e20d9[_0x62a3('0x16')][_0x62a3('0x14')]);}})['catch'](function(_0xdf7295){logger[_0x62a3('0x13')]('FaxMessage,\x20%s,\x20%s',_0x406f49,_0xdf7295);_0x1c8f84(_0xdf7295);});});}exports['CreateFaxMessage']=function(_0x123571){var _0x298bde=this;return new Promise(function(_0xd42e26,_0x531ec7){return db[_0x62a3('0x17')][_0x62a3('0x18')](_0x123571['body'],{'raw':_0x123571['options']?_0x123571[_0x62a3('0x19')][_0x62a3('0x1a')]===undefined?!![]:![]:!![]})[_0x62a3('0xe')](function(_0x5b89d9){logger[_0x62a3('0xf')](_0x62a3('0x1b'),_0x123571);logger['debug'](_0x62a3('0x1b'),_0x123571,JSON[_0x62a3('0x1c')](_0x5b89d9));_0xd42e26(_0x5b89d9);})[_0x62a3('0x1d')](function(_0x276ddc){logger[_0x62a3('0x13')](_0x62a3('0x1b'),_0x276ddc[_0x62a3('0x14')],_0x123571);_0x531ec7(_0x298bde[_0x62a3('0x13')](0x1f4,_0x276ddc[_0x62a3('0x14')]));});});};exports[_0x62a3('0x1e')]=function(_0x46e8cc){var _0x4c8d05=this;return new Promise(function(_0xca1d77,_0x1f202){return db[_0x62a3('0x17')][_0x62a3('0x1f')](_0x46e8cc['body'],{'raw':_0x46e8cc[_0x62a3('0x19')]?_0x46e8cc['options'][_0x62a3('0x1a')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x46e8cc[_0x62a3('0x19')]?_0x46e8cc[_0x62a3('0x19')]['where']||null:null,'attributes':_0x46e8cc[_0x62a3('0x19')]?_0x46e8cc[_0x62a3('0x19')]['attributes']||null:null,'limit':_0x46e8cc[_0x62a3('0x19')]?_0x46e8cc[_0x62a3('0x19')]['limit']||null:null})['then'](function(_0x574914){logger[_0x62a3('0xf')](_0x62a3('0x1e'),_0x46e8cc);logger['debug'](_0x62a3('0x1e'),_0x46e8cc,JSON[_0x62a3('0x1c')](_0x574914));_0xca1d77(_0x574914);})['catch'](function(_0x100a2f){logger['error']('UpdateFaxMessage',_0x100a2f[_0x62a3('0x14')],_0x46e8cc);_0x1f202(_0x4c8d05[_0x62a3('0x13')](0x1f4,_0x100a2f['message']));});});};