Built motion from commit ac06311e.|2.6.28
[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 _0x14be=['../../config/environment','client','http','defaults','redis','localhost','./faxInteraction.socket','request','then','info','request\x20sent','debug','FaxInteraction,\x20%s,\x20%s,\x20%s','error','code','FaxInteraction,\x20%s,\x20%s','message','result','catch','UpdateFaxInteraction','FaxInteraction','body','options','raw','where','limit','stringify','find','addTags','ids','omit','AddTags','lodash','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc'];(function(_0x17aee4,_0x3b7f0f){var _0x34b091=function(_0x53435d){while(--_0x53435d){_0x17aee4['push'](_0x17aee4['shift']());}};_0x34b091(++_0x3b7f0f);}(_0x14be,0x70));var _0xe14b=function(_0x53c7e3,_0x4b7c9f){_0x53c7e3=_0x53c7e3-0x0;var _0x2de5d6=_0x14be[_0x53c7e3];return _0x2de5d6;};'use strict';var _=require(_0xe14b('0x0'));var util=require('util');var moment=require(_0xe14b('0x1'));var BPromise=require(_0xe14b('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xe14b('0x3'));var db=require(_0xe14b('0x4'))['db'];var utils=require(_0xe14b('0x5'));var logger=require(_0xe14b('0x6'))(_0xe14b('0x7'));var config=require(_0xe14b('0x8'));var jayson=require('jayson/promise');var client=jayson[_0xe14b('0x9')][_0xe14b('0xa')]({'port':0x232a});config['redis']=_[_0xe14b('0xb')](config[_0xe14b('0xc')],{'host':_0xe14b('0xd'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xe14b('0xc')]));require(_0xe14b('0xe'))['register'](socket);function respondWithRpcPromise(_0x6f75e3,_0x52dcaf,_0x47a6b1){return new BPromise(function(_0x17a5bc,_0x3b1f0d){return client[_0xe14b('0xf')](_0x6f75e3,_0x47a6b1)[_0xe14b('0x10')](function(_0x22c940){logger[_0xe14b('0x11')]('FaxInteraction,\x20%s,\x20%s',_0x52dcaf,_0xe14b('0x12'));logger[_0xe14b('0x13')](_0xe14b('0x14'),_0x52dcaf,_0xe14b('0x12'),JSON['stringify'](_0x22c940));if(_0x22c940[_0xe14b('0x15')]){if(_0x22c940[_0xe14b('0x15')][_0xe14b('0x16')]===0x1f4){logger[_0xe14b('0x15')](_0xe14b('0x17'),_0x52dcaf,_0x22c940[_0xe14b('0x15')][_0xe14b('0x18')]);return _0x3b1f0d(_0x22c940[_0xe14b('0x15')]['message']);}logger['error'](_0xe14b('0x17'),_0x52dcaf,_0x22c940['error']['message']);return _0x17a5bc(_0x22c940[_0xe14b('0x15')][_0xe14b('0x18')]);}else{logger['info'](_0xe14b('0x17'),_0x52dcaf,_0xe14b('0x12'));_0x17a5bc(_0x22c940[_0xe14b('0x19')]['message']);}})[_0xe14b('0x1a')](function(_0x13b89c){logger['error']('FaxInteraction,\x20%s,\x20%s',_0x52dcaf,_0x13b89c);_0x3b1f0d(_0x13b89c);});});}exports[_0xe14b('0x1b')]=function(_0x58758){var _0x562182=this;return new Promise(function(_0x550618,_0x50a6be){return db[_0xe14b('0x1c')]['update'](_0x58758[_0xe14b('0x1d')],{'raw':_0x58758[_0xe14b('0x1e')]?_0x58758[_0xe14b('0x1e')][_0xe14b('0x1f')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x58758[_0xe14b('0x1e')]?_0x58758['options'][_0xe14b('0x20')]||null:null,'attributes':_0x58758[_0xe14b('0x1e')]?_0x58758[_0xe14b('0x1e')]['attributes']||null:null,'limit':_0x58758[_0xe14b('0x1e')]?_0x58758[_0xe14b('0x1e')][_0xe14b('0x21')]||null:null})[_0xe14b('0x10')](function(_0x27b65d){logger[_0xe14b('0x11')](_0xe14b('0x1b'),_0x58758);logger[_0xe14b('0x13')](_0xe14b('0x1b'),_0x58758,JSON[_0xe14b('0x22')](_0x27b65d));_0x550618(_0x27b65d);})['catch'](function(_0xc7a79e){logger['error'](_0xe14b('0x1b'),_0xc7a79e[_0xe14b('0x18')],_0x58758);_0x50a6be(_0x562182[_0xe14b('0x15')](0x1f4,_0xc7a79e[_0xe14b('0x18')]));});});};exports['AddTagsToFaxInteraction']=function(_0x15d8ac){return new Promise(function(_0x55da78,_0x1892a3){return db['FaxInteraction'][_0xe14b('0x23')]({'where':_0x15d8ac[_0xe14b('0x1e')]?_0x15d8ac['options'][_0xe14b('0x20')]||null:null})[_0xe14b('0x10')](function(_0x383e01){if(_0x383e01){return _0x383e01[_0xe14b('0x24')](_0x15d8ac[_0xe14b('0x1d')][_0xe14b('0x25')],_[_0xe14b('0x26')](_0x15d8ac[_0xe14b('0x1d')],[_0xe14b('0x25'),'id'])||{});}})['spread'](function(_0x59b6d4){logger['info'](_0xe14b('0x27'),_0x15d8ac);logger['debug'](_0xe14b('0x27'),_0x15d8ac,JSON[_0xe14b('0x22')](_0x59b6d4));_0x55da78(_0x59b6d4);})[_0xe14b('0x1a')](function(_0x1f72fb){logger['error']('AddTags',_0x1f72fb[_0xe14b('0x18')],_0x15d8ac);_0x1892a3(_this[_0xe14b('0x15')](0x1f4,_0x1f72fb[_0xe14b('0x18')]));});});};