Built motion from commit cafec4f3.|2.6.31
[motion2.git] / server / api / faxApplication / faxApplication.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 _0xb673=['randomstring','ioredis','../../config/utils','../../config/logger','rpc','jayson/promise','http','FaxApplication,\x20%s,\x20%s','debug','FaxApplication,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','message','info','result','catch','UpdateFaxApplication','FaxApplication','update','options','raw','where','attributes','then','lodash','util','bluebird'];(function(_0x5ceaf5,_0x3ea743){var _0x835d7c=function(_0xc887f9){while(--_0xc887f9){_0x5ceaf5['push'](_0x5ceaf5['shift']());}};_0x835d7c(++_0x3ea743);}(_0xb673,0xa5));var _0x3b67=function(_0x12b3d4,_0x27f5b6){_0x12b3d4=_0x12b3d4-0x0;var _0x321ba4=_0xb673[_0x12b3d4];return _0x321ba4;};'use strict';var _=require(_0x3b67('0x0'));var util=require(_0x3b67('0x1'));var moment=require('moment');var BPromise=require(_0x3b67('0x2'));var rs=require(_0x3b67('0x3'));var fs=require('fs');var Redis=require(_0x3b67('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x3b67('0x5'));var logger=require(_0x3b67('0x6'))(_0x3b67('0x7'));var config=require('../../config/environment');var jayson=require(_0x3b67('0x8'));var client=jayson['client'][_0x3b67('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x3c0f30,_0x3e2fd8,_0x329729){return new BPromise(function(_0x5703ee,_0x4c63d3){return client['request'](_0x3c0f30,_0x329729)['then'](function(_0x404edf){logger['info'](_0x3b67('0xa'),_0x3e2fd8,'request\x20sent');logger[_0x3b67('0xb')](_0x3b67('0xc'),_0x3e2fd8,_0x3b67('0xd'),JSON[_0x3b67('0xe')](_0x404edf));if(_0x404edf['error']){if(_0x404edf['error']['code']===0x1f4){logger['error'](_0x3b67('0xa'),_0x3e2fd8,_0x404edf[_0x3b67('0xf')]['message']);return _0x4c63d3(_0x404edf[_0x3b67('0xf')][_0x3b67('0x10')]);}logger['error'](_0x3b67('0xa'),_0x3e2fd8,_0x404edf[_0x3b67('0xf')][_0x3b67('0x10')]);return _0x5703ee(_0x404edf[_0x3b67('0xf')][_0x3b67('0x10')]);}else{logger[_0x3b67('0x11')]('FaxApplication,\x20%s,\x20%s',_0x3e2fd8,'request\x20sent');_0x5703ee(_0x404edf[_0x3b67('0x12')][_0x3b67('0x10')]);}})[_0x3b67('0x13')](function(_0x1557df){logger['error'](_0x3b67('0xa'),_0x3e2fd8,_0x1557df);_0x4c63d3(_0x1557df);});});}exports[_0x3b67('0x14')]=function(_0x5c4e27){var _0x45da53=this;return new Promise(function(_0x607f4d,_0x124b36){return db[_0x3b67('0x15')][_0x3b67('0x16')](_0x5c4e27['body'],{'raw':_0x5c4e27[_0x3b67('0x17')]?_0x5c4e27[_0x3b67('0x17')][_0x3b67('0x18')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x5c4e27[_0x3b67('0x17')]?_0x5c4e27[_0x3b67('0x17')][_0x3b67('0x19')]||null:null,'attributes':_0x5c4e27[_0x3b67('0x17')]?_0x5c4e27['options'][_0x3b67('0x1a')]||null:null,'limit':_0x5c4e27[_0x3b67('0x17')]?_0x5c4e27[_0x3b67('0x17')]['limit']||null:null})[_0x3b67('0x1b')](function(_0x1bdb9e){logger[_0x3b67('0x11')](_0x3b67('0x14'),_0x5c4e27);logger[_0x3b67('0xb')](_0x3b67('0x14'),_0x5c4e27,JSON[_0x3b67('0xe')](_0x1bdb9e));_0x607f4d(_0x1bdb9e);})[_0x3b67('0x13')](function(_0x3b4e7c){logger[_0x3b67('0xf')](_0x3b67('0x14'),_0x3b4e7c[_0x3b67('0x10')],_0x5c4e27);_0x124b36(_0x45da53[_0x3b67('0xf')](0x1f4,_0x3b4e7c[_0x3b67('0x10')]));});});};