3ff482b107052967cb89f40fd6fcb5982adb4df3
[motion2.git] / server / api / faxInteraction / faxInteraction.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 _0x9b17=['register','request','then','info','FaxInteraction,\x20%s,\x20%s','request\x20sent','debug','error','message','catch','UpdateFaxInteraction','FaxInteraction','update','options','raw','where','attributes','limit','stringify','AddTagsToFaxInteraction','find','addTags','ids','omit','spread','AddTags','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','http','defaults','redis','localhost','socket.io-emitter','./faxInteraction.socket'];(function(_0x5cf55b,_0x4c3b75){var _0x59917b=function(_0x135f28){while(--_0x135f28){_0x5cf55b['push'](_0x5cf55b['shift']());}};_0x59917b(++_0x4c3b75);}(_0x9b17,0xc2));var _0x79b1=function(_0x56d1b7,_0x1d88f5){_0x56d1b7=_0x56d1b7-0x0;var _0x184d91=_0x9b17[_0x56d1b7];return _0x184d91;};'use strict';var _=require(_0x79b1('0x0'));var util=require(_0x79b1('0x1'));var moment=require('moment');var BPromise=require(_0x79b1('0x2'));var rs=require(_0x79b1('0x3'));var fs=require('fs');var Redis=require(_0x79b1('0x4'));var db=require(_0x79b1('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x79b1('0x6'))(_0x79b1('0x7'));var config=require(_0x79b1('0x8'));var jayson=require(_0x79b1('0x9'));var client=jayson['client'][_0x79b1('0xa')]({'port':0x232a});config['redis']=_[_0x79b1('0xb')](config[_0x79b1('0xc')],{'host':_0x79b1('0xd'),'port':0x18eb});var socket=require(_0x79b1('0xe'))(new Redis(config[_0x79b1('0xc')]));require(_0x79b1('0xf'))[_0x79b1('0x10')](socket);function respondWithRpcPromise(_0x4d45b0,_0xa7682b,_0x5c9e65){return new BPromise(function(_0xdf1237,_0x1b03c7){return client[_0x79b1('0x11')](_0x4d45b0,_0x5c9e65)[_0x79b1('0x12')](function(_0x126558){logger[_0x79b1('0x13')](_0x79b1('0x14'),_0xa7682b,_0x79b1('0x15'));logger[_0x79b1('0x16')]('FaxInteraction,\x20%s,\x20%s,\x20%s',_0xa7682b,_0x79b1('0x15'),JSON['stringify'](_0x126558));if(_0x126558[_0x79b1('0x17')]){if(_0x126558[_0x79b1('0x17')]['code']===0x1f4){logger[_0x79b1('0x17')](_0x79b1('0x14'),_0xa7682b,_0x126558['error']['message']);return _0x1b03c7(_0x126558['error'][_0x79b1('0x18')]);}logger[_0x79b1('0x17')](_0x79b1('0x14'),_0xa7682b,_0x126558[_0x79b1('0x17')][_0x79b1('0x18')]);return _0xdf1237(_0x126558[_0x79b1('0x17')]['message']);}else{logger[_0x79b1('0x13')](_0x79b1('0x14'),_0xa7682b,'request\x20sent');_0xdf1237(_0x126558['result'][_0x79b1('0x18')]);}})[_0x79b1('0x19')](function(_0x1d7d3b){logger['error'](_0x79b1('0x14'),_0xa7682b,_0x1d7d3b);_0x1b03c7(_0x1d7d3b);});});}exports[_0x79b1('0x1a')]=function(_0x182359){var _0xcb2107=this;return new Promise(function(_0x512722,_0x50984b){return db[_0x79b1('0x1b')][_0x79b1('0x1c')](_0x182359['body'],{'raw':_0x182359[_0x79b1('0x1d')]?_0x182359[_0x79b1('0x1d')][_0x79b1('0x1e')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x182359[_0x79b1('0x1d')]?_0x182359[_0x79b1('0x1d')][_0x79b1('0x1f')]||null:null,'attributes':_0x182359[_0x79b1('0x1d')]?_0x182359[_0x79b1('0x1d')][_0x79b1('0x20')]||null:null,'limit':_0x182359[_0x79b1('0x1d')]?_0x182359['options'][_0x79b1('0x21')]||null:null})[_0x79b1('0x12')](function(_0x48b2f4){logger[_0x79b1('0x13')](_0x79b1('0x1a'),_0x182359);logger[_0x79b1('0x16')]('UpdateFaxInteraction',_0x182359,JSON[_0x79b1('0x22')](_0x48b2f4));_0x512722(_0x48b2f4);})[_0x79b1('0x19')](function(_0x63136b){logger[_0x79b1('0x17')](_0x79b1('0x1a'),_0x63136b[_0x79b1('0x18')],_0x182359);_0x50984b(_0xcb2107[_0x79b1('0x17')](0x1f4,_0x63136b[_0x79b1('0x18')]));});});};exports[_0x79b1('0x23')]=function(_0x55f7fc){return new Promise(function(_0x4da92d,_0xbcba70){return db[_0x79b1('0x1b')][_0x79b1('0x24')]({'where':_0x55f7fc[_0x79b1('0x1d')]?_0x55f7fc[_0x79b1('0x1d')][_0x79b1('0x1f')]||null:null})[_0x79b1('0x12')](function(_0x478ee2){if(_0x478ee2){return _0x478ee2[_0x79b1('0x25')](_0x55f7fc['body'][_0x79b1('0x26')],_[_0x79b1('0x27')](_0x55f7fc['body'],[_0x79b1('0x26'),'id'])||{});}})[_0x79b1('0x28')](function(_0x15b883){logger[_0x79b1('0x13')](_0x79b1('0x29'),_0x55f7fc);logger[_0x79b1('0x16')]('AddTags',_0x55f7fc,JSON[_0x79b1('0x22')](_0x15b883));_0x4da92d(_0x15b883);})[_0x79b1('0x19')](function(_0x257122){logger[_0x79b1('0x17')](_0x79b1('0x29'),_0x257122[_0x79b1('0x18')],_0x55f7fc);_0xbcba70(_this[_0x79b1('0x17')](0x1f4,_0x257122[_0x79b1('0x18')]));});});};