Built motion from commit (unavailable).|2.4.16
[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 _0xf5b0=['client','http','redis','defaults','localhost','socket.io-emitter','./faxMessage.socket','register','request','then','FaxMessage,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','info','result','catch','CreateFaxMessage','FaxMessage','create','options','raw','update','body','where','attributes','limit','UpdateFaxMessage','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise'];(function(_0x59558c,_0x428b2f){var _0x1dda36=function(_0x46044d){while(--_0x46044d){_0x59558c['push'](_0x59558c['shift']());}};_0x1dda36(++_0x428b2f);}(_0xf5b0,0x10e));var _0x0f5b=function(_0x411add,_0x1aed38){_0x411add=_0x411add-0x0;var _0x238242=_0xf5b0[_0x411add];return _0x238242;};'use strict';var _=require(_0x0f5b('0x0'));var util=require(_0x0f5b('0x1'));var moment=require(_0x0f5b('0x2'));var BPromise=require(_0x0f5b('0x3'));var rs=require(_0x0f5b('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x0f5b('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x0f5b('0x6'))(_0x0f5b('0x7'));var config=require(_0x0f5b('0x8'));var jayson=require(_0x0f5b('0x9'));var client=jayson[_0x0f5b('0xa')][_0x0f5b('0xb')]({'port':0x232a});config[_0x0f5b('0xc')]=_[_0x0f5b('0xd')](config[_0x0f5b('0xc')],{'host':_0x0f5b('0xe'),'port':0x18eb});var socket=require(_0x0f5b('0xf'))(new Redis(config[_0x0f5b('0xc')]));require(_0x0f5b('0x10'))[_0x0f5b('0x11')](socket);function respondWithRpcPromise(_0x31f60e,_0x31eea9,_0x45dae4){return new BPromise(function(_0x4e169f,_0x1378f6){return client[_0x0f5b('0x12')](_0x31f60e,_0x45dae4)[_0x0f5b('0x13')](function(_0x3cf5a1){logger['info'](_0x0f5b('0x14'),_0x31eea9,_0x0f5b('0x15'));logger[_0x0f5b('0x16')]('FaxMessage,\x20%s,\x20%s,\x20%s',_0x31eea9,_0x0f5b('0x15'),JSON[_0x0f5b('0x17')](_0x3cf5a1));if(_0x3cf5a1['error']){if(_0x3cf5a1[_0x0f5b('0x18')]['code']===0x1f4){logger[_0x0f5b('0x18')](_0x0f5b('0x14'),_0x31eea9,_0x3cf5a1['error'][_0x0f5b('0x19')]);return _0x1378f6(_0x3cf5a1[_0x0f5b('0x18')]['message']);}logger[_0x0f5b('0x18')]('FaxMessage,\x20%s,\x20%s',_0x31eea9,_0x3cf5a1[_0x0f5b('0x18')]['message']);return _0x4e169f(_0x3cf5a1[_0x0f5b('0x18')][_0x0f5b('0x19')]);}else{logger[_0x0f5b('0x1a')](_0x0f5b('0x14'),_0x31eea9,_0x0f5b('0x15'));_0x4e169f(_0x3cf5a1[_0x0f5b('0x1b')][_0x0f5b('0x19')]);}})[_0x0f5b('0x1c')](function(_0x16d712){logger[_0x0f5b('0x18')](_0x0f5b('0x14'),_0x31eea9,_0x16d712);_0x1378f6(_0x16d712);});});}exports[_0x0f5b('0x1d')]=function(_0x35dc75){var _0x111b27=this;return new Promise(function(_0x2961c7,_0x3e38e5){return db[_0x0f5b('0x1e')][_0x0f5b('0x1f')](_0x35dc75['body'],{'raw':_0x35dc75[_0x0f5b('0x20')]?_0x35dc75['options'][_0x0f5b('0x21')]===undefined?!![]:![]:!![]})['then'](function(_0x4a0278){logger[_0x0f5b('0x1a')]('CreateFaxMessage',_0x35dc75);logger[_0x0f5b('0x16')](_0x0f5b('0x1d'),_0x35dc75,JSON[_0x0f5b('0x17')](_0x4a0278));_0x2961c7(_0x4a0278);})[_0x0f5b('0x1c')](function(_0x30dce5){logger['error'](_0x0f5b('0x1d'),_0x30dce5[_0x0f5b('0x19')],_0x35dc75);_0x3e38e5(_0x111b27[_0x0f5b('0x18')](0x1f4,_0x30dce5[_0x0f5b('0x19')]));});});};exports['UpdateFaxMessage']=function(_0x5b3b24){var _0x280a0b=this;return new Promise(function(_0x256bd2,_0x254a96){return db[_0x0f5b('0x1e')][_0x0f5b('0x22')](_0x5b3b24[_0x0f5b('0x23')],{'raw':_0x5b3b24[_0x0f5b('0x20')]?_0x5b3b24[_0x0f5b('0x20')][_0x0f5b('0x21')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x5b3b24[_0x0f5b('0x20')]?_0x5b3b24['options'][_0x0f5b('0x24')]||null:null,'attributes':_0x5b3b24[_0x0f5b('0x20')]?_0x5b3b24['options'][_0x0f5b('0x25')]||null:null,'limit':_0x5b3b24[_0x0f5b('0x20')]?_0x5b3b24[_0x0f5b('0x20')][_0x0f5b('0x26')]||null:null})['then'](function(_0x1946ff){logger['info'](_0x0f5b('0x27'),_0x5b3b24);logger[_0x0f5b('0x16')](_0x0f5b('0x27'),_0x5b3b24,JSON[_0x0f5b('0x17')](_0x1946ff));_0x256bd2(_0x1946ff);})[_0x0f5b('0x1c')](function(_0x729d27){logger['error']('UpdateFaxMessage',_0x729d27[_0x0f5b('0x19')],_0x5b3b24);_0x254a96(_0x280a0b[_0x0f5b('0x18')](0x1f4,_0x729d27[_0x0f5b('0x19')]));});});};