Built motion from commit (unavailable).|2.5.2
[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 _0x584a=['request\x20sent','FaxMessage,\x20%s,\x20%s,\x20%s','stringify','error','message','CreateFaxMessage','FaxMessage','create','body','options','raw','debug','catch','UpdateFaxMessage','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','rpc','client','http','defaults','redis','./faxMessage.socket','register','request','then','info','FaxMessage,\x20%s,\x20%s'];(function(_0x4eb87b,_0x368127){var _0x5d8ea1=function(_0x49c6c6){while(--_0x49c6c6){_0x4eb87b['push'](_0x4eb87b['shift']());}};_0x5d8ea1(++_0x368127);}(_0x584a,0x1c0));var _0xa584=function(_0x17eba5,_0x434f32){_0x17eba5=_0x17eba5-0x0;var _0x1aa6f1=_0x584a[_0x17eba5];return _0x1aa6f1;};'use strict';var _=require(_0xa584('0x0'));var util=require(_0xa584('0x1'));var moment=require('moment');var BPromise=require(_0xa584('0x2'));var rs=require(_0xa584('0x3'));var fs=require('fs');var Redis=require(_0xa584('0x4'));var db=require(_0xa584('0x5'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0xa584('0x6'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0xa584('0x7')][_0xa584('0x8')]({'port':0x232a});config['redis']=_[_0xa584('0x9')](config[_0xa584('0xa')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0xa584('0xb'))[_0xa584('0xc')](socket);function respondWithRpcPromise(_0x2b0bd2,_0x13910c,_0x42bf8c){return new BPromise(function(_0x37c285,_0x1f9081){return client[_0xa584('0xd')](_0x2b0bd2,_0x42bf8c)[_0xa584('0xe')](function(_0x15bf3c){logger[_0xa584('0xf')](_0xa584('0x10'),_0x13910c,_0xa584('0x11'));logger['debug'](_0xa584('0x12'),_0x13910c,_0xa584('0x11'),JSON[_0xa584('0x13')](_0x15bf3c));if(_0x15bf3c[_0xa584('0x14')]){if(_0x15bf3c[_0xa584('0x14')]['code']===0x1f4){logger[_0xa584('0x14')](_0xa584('0x10'),_0x13910c,_0x15bf3c[_0xa584('0x14')][_0xa584('0x15')]);return _0x1f9081(_0x15bf3c[_0xa584('0x14')]['message']);}logger[_0xa584('0x14')]('FaxMessage,\x20%s,\x20%s',_0x13910c,_0x15bf3c[_0xa584('0x14')][_0xa584('0x15')]);return _0x37c285(_0x15bf3c[_0xa584('0x14')]['message']);}else{logger[_0xa584('0xf')](_0xa584('0x10'),_0x13910c,_0xa584('0x11'));_0x37c285(_0x15bf3c['result'][_0xa584('0x15')]);}})['catch'](function(_0x278868){logger[_0xa584('0x14')]('FaxMessage,\x20%s,\x20%s',_0x13910c,_0x278868);_0x1f9081(_0x278868);});});}exports[_0xa584('0x16')]=function(_0x203ec4){var _0x2fb7da=this;return new Promise(function(_0xf9097e,_0xd6f63c){return db[_0xa584('0x17')][_0xa584('0x18')](_0x203ec4[_0xa584('0x19')],{'raw':_0x203ec4[_0xa584('0x1a')]?_0x203ec4[_0xa584('0x1a')][_0xa584('0x1b')]===undefined?!![]:![]:!![]})['then'](function(_0x5c3e32){logger[_0xa584('0xf')](_0xa584('0x16'),_0x203ec4);logger[_0xa584('0x1c')](_0xa584('0x16'),_0x203ec4,JSON[_0xa584('0x13')](_0x5c3e32));_0xf9097e(_0x5c3e32);})[_0xa584('0x1d')](function(_0x33bf24){logger[_0xa584('0x14')](_0xa584('0x16'),_0x33bf24['message'],_0x203ec4);_0xd6f63c(_0x2fb7da[_0xa584('0x14')](0x1f4,_0x33bf24['message']));});});};exports[_0xa584('0x1e')]=function(_0xda7821){var _0x1f1c73=this;return new Promise(function(_0x3d11cf,_0x570242){return db[_0xa584('0x17')]['update'](_0xda7821[_0xa584('0x19')],{'raw':_0xda7821[_0xa584('0x1a')]?_0xda7821[_0xa584('0x1a')][_0xa584('0x1b')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0xda7821['options']?_0xda7821[_0xa584('0x1a')]['where']||null:null,'attributes':_0xda7821['options']?_0xda7821[_0xa584('0x1a')]['attributes']||null:null,'limit':_0xda7821[_0xa584('0x1a')]?_0xda7821[_0xa584('0x1a')]['limit']||null:null})[_0xa584('0xe')](function(_0x8300d8){logger[_0xa584('0xf')](_0xa584('0x1e'),_0xda7821);logger[_0xa584('0x1c')](_0xa584('0x1e'),_0xda7821,JSON[_0xa584('0x13')](_0x8300d8));_0x3d11cf(_0x8300d8);})['catch'](function(_0xa7b2a5){logger[_0xa584('0x14')](_0xa584('0x1e'),_0xa7b2a5['message'],_0xda7821);_0x570242(_0x1f1c73[_0xa584('0x14')](0x1f4,_0xa7b2a5[_0xa584('0x15')]));});});};