Built motion from commit 9d0783e6.|2.6.13
[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 _0x1615=['catch','UpdateFaxInteraction','FaxInteraction','update','body','options','raw','where','attributes','find','addTags','ids','omit','AddTags','util','moment','randomstring','rpc','../../config/environment','jayson/promise','client','http','redis','localhost','socket.io-emitter','./faxInteraction.socket','register','request','then','info','FaxInteraction,\x20%s,\x20%s','request\x20sent','debug','FaxInteraction,\x20%s,\x20%s,\x20%s','stringify','code','error','message','result'];(function(_0x4e9f29,_0x1bbcbf){var _0x8e1ab3=function(_0x4a4e6b){while(--_0x4a4e6b){_0x4e9f29['push'](_0x4e9f29['shift']());}};_0x8e1ab3(++_0x1bbcbf);}(_0x1615,0x194));var _0x5161=function(_0x170d24,_0xafcd1d){_0x170d24=_0x170d24-0x0;var _0x3c46b1=_0x1615[_0x170d24];return _0x3c46b1;};'use strict';var _=require('lodash');var util=require(_0x5161('0x0'));var moment=require(_0x5161('0x1'));var BPromise=require('bluebird');var rs=require(_0x5161('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x5161('0x3'));var config=require(_0x5161('0x4'));var jayson=require(_0x5161('0x5'));var client=jayson[_0x5161('0x6')][_0x5161('0x7')]({'port':0x232a});config[_0x5161('0x8')]=_['defaults'](config[_0x5161('0x8')],{'host':_0x5161('0x9'),'port':0x18eb});var socket=require(_0x5161('0xa'))(new Redis(config['redis']));require(_0x5161('0xb'))[_0x5161('0xc')](socket);function respondWithRpcPromise(_0xbd6167,_0x40a0d7,_0x2b50d7){return new BPromise(function(_0x9e23f9,_0x2402a6){return client[_0x5161('0xd')](_0xbd6167,_0x2b50d7)[_0x5161('0xe')](function(_0x4e1897){logger[_0x5161('0xf')](_0x5161('0x10'),_0x40a0d7,_0x5161('0x11'));logger[_0x5161('0x12')](_0x5161('0x13'),_0x40a0d7,_0x5161('0x11'),JSON[_0x5161('0x14')](_0x4e1897));if(_0x4e1897['error']){if(_0x4e1897['error'][_0x5161('0x15')]===0x1f4){logger[_0x5161('0x16')]('FaxInteraction,\x20%s,\x20%s',_0x40a0d7,_0x4e1897[_0x5161('0x16')][_0x5161('0x17')]);return _0x2402a6(_0x4e1897['error'][_0x5161('0x17')]);}logger['error'](_0x5161('0x10'),_0x40a0d7,_0x4e1897[_0x5161('0x16')][_0x5161('0x17')]);return _0x9e23f9(_0x4e1897['error'][_0x5161('0x17')]);}else{logger['info'](_0x5161('0x10'),_0x40a0d7,_0x5161('0x11'));_0x9e23f9(_0x4e1897[_0x5161('0x18')][_0x5161('0x17')]);}})[_0x5161('0x19')](function(_0xd1169e){logger['error']('FaxInteraction,\x20%s,\x20%s',_0x40a0d7,_0xd1169e);_0x2402a6(_0xd1169e);});});}exports[_0x5161('0x1a')]=function(_0x51c04b){var _0x407595=this;return new Promise(function(_0x3dd853,_0x34cb7e){return db[_0x5161('0x1b')][_0x5161('0x1c')](_0x51c04b[_0x5161('0x1d')],{'raw':_0x51c04b[_0x5161('0x1e')]?_0x51c04b[_0x5161('0x1e')][_0x5161('0x1f')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x51c04b[_0x5161('0x1e')]?_0x51c04b[_0x5161('0x1e')][_0x5161('0x20')]||null:null,'attributes':_0x51c04b[_0x5161('0x1e')]?_0x51c04b[_0x5161('0x1e')][_0x5161('0x21')]||null:null,'limit':_0x51c04b[_0x5161('0x1e')]?_0x51c04b[_0x5161('0x1e')]['limit']||null:null})[_0x5161('0xe')](function(_0x33715a){logger['info']('UpdateFaxInteraction',_0x51c04b);logger[_0x5161('0x12')](_0x5161('0x1a'),_0x51c04b,JSON['stringify'](_0x33715a));_0x3dd853(_0x33715a);})[_0x5161('0x19')](function(_0x25e7ee){logger[_0x5161('0x16')](_0x5161('0x1a'),_0x25e7ee[_0x5161('0x17')],_0x51c04b);_0x34cb7e(_0x407595['error'](0x1f4,_0x25e7ee['message']));});});};exports['AddTagsToFaxInteraction']=function(_0x1a6ec6){return new Promise(function(_0x352f46,_0x48493e){return db[_0x5161('0x1b')][_0x5161('0x22')]({'where':_0x1a6ec6[_0x5161('0x1e')]?_0x1a6ec6[_0x5161('0x1e')][_0x5161('0x20')]||null:null})['then'](function(_0x3bb172){if(_0x3bb172){return _0x3bb172[_0x5161('0x23')](_0x1a6ec6['body'][_0x5161('0x24')],_[_0x5161('0x25')](_0x1a6ec6['body'],['ids','id'])||{});}})['spread'](function(_0x232573){logger[_0x5161('0xf')](_0x5161('0x26'),_0x1a6ec6);logger[_0x5161('0x12')](_0x5161('0x26'),_0x1a6ec6,JSON[_0x5161('0x14')](_0x232573));_0x352f46(_0x232573);})[_0x5161('0x19')](function(_0x31f06a){logger[_0x5161('0x16')]('AddTags',_0x31f06a[_0x5161('0x17')],_0x1a6ec6);_0x48493e(_this[_0x5161('0x16')](0x1f4,_0x31f06a[_0x5161('0x17')]));});});};