Built motion from commit 753c950e.|2.5.42
[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 _0x1cd7=['addTags','body','ids','omit','AddTags','lodash','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','./faxInteraction.socket','register','request','then','FaxInteraction,\x20%s,\x20%s','request\x20sent','FaxInteraction,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','UpdateFaxInteraction','FaxInteraction','update','options','raw','where','limit','debug','AddTagsToFaxInteraction','find'];(function(_0x1be3b3,_0x4335ee){var _0x4f8b2d=function(_0x1d955f){while(--_0x1d955f){_0x1be3b3['push'](_0x1be3b3['shift']());}};_0x4f8b2d(++_0x4335ee);}(_0x1cd7,0x165));var _0x71cd=function(_0x1bba53,_0x498b0a){_0x1bba53=_0x1bba53-0x0;var _0x10ad9f=_0x1cd7[_0x1bba53];return _0x10ad9f;};'use strict';var _=require(_0x71cd('0x0'));var util=require('util');var moment=require(_0x71cd('0x1'));var BPromise=require('bluebird');var rs=require(_0x71cd('0x2'));var fs=require('fs');var Redis=require(_0x71cd('0x3'));var db=require(_0x71cd('0x4'))['db'];var utils=require(_0x71cd('0x5'));var logger=require(_0x71cd('0x6'))(_0x71cd('0x7'));var config=require(_0x71cd('0x8'));var jayson=require(_0x71cd('0x9'));var client=jayson[_0x71cd('0xa')][_0x71cd('0xb')]({'port':0x232a});config[_0x71cd('0xc')]=_[_0x71cd('0xd')](config[_0x71cd('0xc')],{'host':_0x71cd('0xe'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x71cd('0xc')]));require(_0x71cd('0xf'))[_0x71cd('0x10')](socket);function respondWithRpcPromise(_0x3b184b,_0x417e6d,_0x1f1159){return new BPromise(function(_0x5dddf8,_0xd38ecd){return client[_0x71cd('0x11')](_0x3b184b,_0x1f1159)[_0x71cd('0x12')](function(_0x46cff7){logger['info'](_0x71cd('0x13'),_0x417e6d,_0x71cd('0x14'));logger['debug'](_0x71cd('0x15'),_0x417e6d,'request\x20sent',JSON[_0x71cd('0x16')](_0x46cff7));if(_0x46cff7[_0x71cd('0x17')]){if(_0x46cff7[_0x71cd('0x17')][_0x71cd('0x18')]===0x1f4){logger[_0x71cd('0x17')](_0x71cd('0x13'),_0x417e6d,_0x46cff7[_0x71cd('0x17')][_0x71cd('0x19')]);return _0xd38ecd(_0x46cff7['error']['message']);}logger['error'](_0x71cd('0x13'),_0x417e6d,_0x46cff7[_0x71cd('0x17')][_0x71cd('0x19')]);return _0x5dddf8(_0x46cff7['error']['message']);}else{logger[_0x71cd('0x1a')]('FaxInteraction,\x20%s,\x20%s',_0x417e6d,_0x71cd('0x14'));_0x5dddf8(_0x46cff7[_0x71cd('0x1b')]['message']);}})[_0x71cd('0x1c')](function(_0x2d61eb){logger[_0x71cd('0x17')](_0x71cd('0x13'),_0x417e6d,_0x2d61eb);_0xd38ecd(_0x2d61eb);});});}exports[_0x71cd('0x1d')]=function(_0xb4a059){var _0x3ebf23=this;return new Promise(function(_0x41d8a7,_0x196589){return db[_0x71cd('0x1e')][_0x71cd('0x1f')](_0xb4a059['body'],{'raw':_0xb4a059[_0x71cd('0x20')]?_0xb4a059[_0x71cd('0x20')][_0x71cd('0x21')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0xb4a059['options']?_0xb4a059[_0x71cd('0x20')][_0x71cd('0x22')]||null:null,'attributes':_0xb4a059['options']?_0xb4a059[_0x71cd('0x20')]['attributes']||null:null,'limit':_0xb4a059[_0x71cd('0x20')]?_0xb4a059['options'][_0x71cd('0x23')]||null:null})[_0x71cd('0x12')](function(_0x840d52){logger[_0x71cd('0x1a')](_0x71cd('0x1d'),_0xb4a059);logger[_0x71cd('0x24')](_0x71cd('0x1d'),_0xb4a059,JSON[_0x71cd('0x16')](_0x840d52));_0x41d8a7(_0x840d52);})[_0x71cd('0x1c')](function(_0x4fcd18){logger['error']('UpdateFaxInteraction',_0x4fcd18[_0x71cd('0x19')],_0xb4a059);_0x196589(_0x3ebf23[_0x71cd('0x17')](0x1f4,_0x4fcd18['message']));});});};exports[_0x71cd('0x25')]=function(_0x140e55){return new Promise(function(_0x2a3f30,_0x5e70b8){return db[_0x71cd('0x1e')][_0x71cd('0x26')]({'where':_0x140e55['options']?_0x140e55[_0x71cd('0x20')][_0x71cd('0x22')]||null:null})['then'](function(_0x139dde){if(_0x139dde){return _0x139dde[_0x71cd('0x27')](_0x140e55[_0x71cd('0x28')][_0x71cd('0x29')],_[_0x71cd('0x2a')](_0x140e55[_0x71cd('0x28')],[_0x71cd('0x29'),'id'])||{});}})['spread'](function(_0x2a640b){logger[_0x71cd('0x1a')](_0x71cd('0x2b'),_0x140e55);logger[_0x71cd('0x24')](_0x71cd('0x2b'),_0x140e55,JSON[_0x71cd('0x16')](_0x2a640b));_0x2a3f30(_0x2a640b);})[_0x71cd('0x1c')](function(_0x240eb9){logger[_0x71cd('0x17')]('AddTags',_0x240eb9[_0x71cd('0x19')],_0x140e55);_0x5e70b8(_this[_0x71cd('0x17')](0x1f4,_0x240eb9[_0x71cd('0x19')]));});});};