Built motion from commit da617fac.|2.6.6
[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 _0x281a=['AddTagsToFaxInteraction','addTags','ids','omit','spread','AddTags','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','redis','defaults','localhost','register','request','then','info','FaxInteraction,\x20%s,\x20%s','request\x20sent','FaxInteraction,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','UpdateFaxInteraction','FaxInteraction','body','options','where','attributes','limit','stringify'];(function(_0x43a45e,_0x4f9fca){var _0x1058f5=function(_0x1f4ba9){while(--_0x1f4ba9){_0x43a45e['push'](_0x43a45e['shift']());}};_0x1058f5(++_0x4f9fca);}(_0x281a,0xa6));var _0xa281=function(_0x344a3f,_0x579a22){_0x344a3f=_0x344a3f-0x0;var _0x264712=_0x281a[_0x344a3f];return _0x264712;};'use strict';var _=require('lodash');var util=require(_0xa281('0x0'));var moment=require(_0xa281('0x1'));var BPromise=require(_0xa281('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xa281('0x3'));var db=require(_0xa281('0x4'))['db'];var utils=require(_0xa281('0x5'));var logger=require(_0xa281('0x6'))(_0xa281('0x7'));var config=require(_0xa281('0x8'));var jayson=require(_0xa281('0x9'));var client=jayson['client'][_0xa281('0xa')]({'port':0x232a});config[_0xa281('0xb')]=_[_0xa281('0xc')](config[_0xa281('0xb')],{'host':_0xa281('0xd'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xa281('0xb')]));require('./faxInteraction.socket')[_0xa281('0xe')](socket);function respondWithRpcPromise(_0x5e35f2,_0x2f5575,_0x48d052){return new BPromise(function(_0x26e694,_0x5e0111){return client[_0xa281('0xf')](_0x5e35f2,_0x48d052)[_0xa281('0x10')](function(_0x390622){logger[_0xa281('0x11')](_0xa281('0x12'),_0x2f5575,_0xa281('0x13'));logger['debug'](_0xa281('0x14'),_0x2f5575,_0xa281('0x13'),JSON['stringify'](_0x390622));if(_0x390622[_0xa281('0x15')]){if(_0x390622[_0xa281('0x15')][_0xa281('0x16')]===0x1f4){logger[_0xa281('0x15')](_0xa281('0x12'),_0x2f5575,_0x390622['error']['message']);return _0x5e0111(_0x390622[_0xa281('0x15')][_0xa281('0x17')]);}logger[_0xa281('0x15')](_0xa281('0x12'),_0x2f5575,_0x390622[_0xa281('0x15')][_0xa281('0x17')]);return _0x26e694(_0x390622[_0xa281('0x15')][_0xa281('0x17')]);}else{logger[_0xa281('0x11')]('FaxInteraction,\x20%s,\x20%s',_0x2f5575,_0xa281('0x13'));_0x26e694(_0x390622[_0xa281('0x18')][_0xa281('0x17')]);}})[_0xa281('0x19')](function(_0x4e9fc2){logger[_0xa281('0x15')](_0xa281('0x12'),_0x2f5575,_0x4e9fc2);_0x5e0111(_0x4e9fc2);});});}exports[_0xa281('0x1a')]=function(_0x1c0686){var _0x4c1e99=this;return new Promise(function(_0x1a3f1a,_0x5d04c2){return db[_0xa281('0x1b')]['update'](_0x1c0686[_0xa281('0x1c')],{'raw':_0x1c0686[_0xa281('0x1d')]?_0x1c0686[_0xa281('0x1d')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x1c0686[_0xa281('0x1d')]?_0x1c0686[_0xa281('0x1d')][_0xa281('0x1e')]||null:null,'attributes':_0x1c0686['options']?_0x1c0686[_0xa281('0x1d')][_0xa281('0x1f')]||null:null,'limit':_0x1c0686[_0xa281('0x1d')]?_0x1c0686[_0xa281('0x1d')][_0xa281('0x20')]||null:null})[_0xa281('0x10')](function(_0x17e90c){logger[_0xa281('0x11')](_0xa281('0x1a'),_0x1c0686);logger['debug'](_0xa281('0x1a'),_0x1c0686,JSON[_0xa281('0x21')](_0x17e90c));_0x1a3f1a(_0x17e90c);})['catch'](function(_0x388c1d){logger[_0xa281('0x15')](_0xa281('0x1a'),_0x388c1d[_0xa281('0x17')],_0x1c0686);_0x5d04c2(_0x4c1e99[_0xa281('0x15')](0x1f4,_0x388c1d[_0xa281('0x17')]));});});};exports[_0xa281('0x22')]=function(_0x1f2a50){return new Promise(function(_0x52d5e3,_0x35b297){return db[_0xa281('0x1b')]['find']({'where':_0x1f2a50[_0xa281('0x1d')]?_0x1f2a50[_0xa281('0x1d')][_0xa281('0x1e')]||null:null})[_0xa281('0x10')](function(_0x112ac6){if(_0x112ac6){return _0x112ac6[_0xa281('0x23')](_0x1f2a50['body'][_0xa281('0x24')],_[_0xa281('0x25')](_0x1f2a50[_0xa281('0x1c')],[_0xa281('0x24'),'id'])||{});}})[_0xa281('0x26')](function(_0x5c0b43){logger[_0xa281('0x11')]('AddTags',_0x1f2a50);logger['debug'](_0xa281('0x27'),_0x1f2a50,JSON[_0xa281('0x21')](_0x5c0b43));_0x52d5e3(_0x5c0b43);})[_0xa281('0x19')](function(_0x36ccd5){logger['error'](_0xa281('0x27'),_0x36ccd5[_0xa281('0x17')],_0x1f2a50);_0x35b297(_this['error'](0x1f4,_0x36ccd5[_0xa281('0x17')]));});});};