ad401fb3d3b797aa855d7298c4e694a3bde966b0
[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 _0xf34c=['FaxInteraction','find','addTags','ids','omit','spread','AddTags','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','jayson/promise','client','http','defaults','redis','localhost','socket.io-emitter','register','request','then','info','request\x20sent','debug','FaxInteraction,\x20%s,\x20%s,\x20%s','error','code','FaxInteraction,\x20%s,\x20%s','message','result','catch','UpdateFaxInteraction','update','body','options','raw','where','attributes','limit','stringify'];(function(_0x37085b,_0x161469){var _0x3c152a=function(_0x3c9a25){while(--_0x3c9a25){_0x37085b['push'](_0x37085b['shift']());}};_0x3c152a(++_0x161469);}(_0xf34c,0x8e));var _0xcf34=function(_0x2ce2d1,_0x5be8fd){_0x2ce2d1=_0x2ce2d1-0x0;var _0x1df959=_0xf34c[_0x2ce2d1];return _0x1df959;};'use strict';var _=require(_0xcf34('0x0'));var util=require(_0xcf34('0x1'));var moment=require(_0xcf34('0x2'));var BPromise=require(_0xcf34('0x3'));var rs=require(_0xcf34('0x4'));var fs=require('fs');var Redis=require(_0xcf34('0x5'));var db=require(_0xcf34('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0xcf34('0x7'))(_0xcf34('0x8'));var config=require('../../config/environment');var jayson=require(_0xcf34('0x9'));var client=jayson[_0xcf34('0xa')][_0xcf34('0xb')]({'port':0x232a});config['redis']=_[_0xcf34('0xc')](config[_0xcf34('0xd')],{'host':_0xcf34('0xe'),'port':0x18eb});var socket=require(_0xcf34('0xf'))(new Redis(config['redis']));require('./faxInteraction.socket')[_0xcf34('0x10')](socket);function respondWithRpcPromise(_0x3014d7,_0x1ee939,_0x16220a){return new BPromise(function(_0x5c5be4,_0x483c7f){return client[_0xcf34('0x11')](_0x3014d7,_0x16220a)[_0xcf34('0x12')](function(_0x81eec2){logger[_0xcf34('0x13')]('FaxInteraction,\x20%s,\x20%s',_0x1ee939,_0xcf34('0x14'));logger[_0xcf34('0x15')](_0xcf34('0x16'),_0x1ee939,'request\x20sent',JSON['stringify'](_0x81eec2));if(_0x81eec2[_0xcf34('0x17')]){if(_0x81eec2[_0xcf34('0x17')][_0xcf34('0x18')]===0x1f4){logger[_0xcf34('0x17')](_0xcf34('0x19'),_0x1ee939,_0x81eec2['error']['message']);return _0x483c7f(_0x81eec2[_0xcf34('0x17')][_0xcf34('0x1a')]);}logger[_0xcf34('0x17')](_0xcf34('0x19'),_0x1ee939,_0x81eec2['error'][_0xcf34('0x1a')]);return _0x5c5be4(_0x81eec2[_0xcf34('0x17')][_0xcf34('0x1a')]);}else{logger[_0xcf34('0x13')](_0xcf34('0x19'),_0x1ee939,_0xcf34('0x14'));_0x5c5be4(_0x81eec2[_0xcf34('0x1b')][_0xcf34('0x1a')]);}})[_0xcf34('0x1c')](function(_0x155c01){logger[_0xcf34('0x17')](_0xcf34('0x19'),_0x1ee939,_0x155c01);_0x483c7f(_0x155c01);});});}exports[_0xcf34('0x1d')]=function(_0x538488){var _0x11ffcb=this;return new Promise(function(_0x3fde21,_0x27ce85){return db['FaxInteraction'][_0xcf34('0x1e')](_0x538488[_0xcf34('0x1f')],{'raw':_0x538488['options']?_0x538488[_0xcf34('0x20')][_0xcf34('0x21')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x538488[_0xcf34('0x20')]?_0x538488[_0xcf34('0x20')][_0xcf34('0x22')]||null:null,'attributes':_0x538488[_0xcf34('0x20')]?_0x538488['options'][_0xcf34('0x23')]||null:null,'limit':_0x538488[_0xcf34('0x20')]?_0x538488[_0xcf34('0x20')][_0xcf34('0x24')]||null:null})[_0xcf34('0x12')](function(_0xad6a04){logger['info'](_0xcf34('0x1d'),_0x538488);logger['debug'](_0xcf34('0x1d'),_0x538488,JSON[_0xcf34('0x25')](_0xad6a04));_0x3fde21(_0xad6a04);})[_0xcf34('0x1c')](function(_0x4bf5a5){logger[_0xcf34('0x17')](_0xcf34('0x1d'),_0x4bf5a5[_0xcf34('0x1a')],_0x538488);_0x27ce85(_0x11ffcb['error'](0x1f4,_0x4bf5a5[_0xcf34('0x1a')]));});});};exports['AddTagsToFaxInteraction']=function(_0x56e8ec){return new Promise(function(_0x142954,_0x15f9a0){return db[_0xcf34('0x26')][_0xcf34('0x27')]({'where':_0x56e8ec[_0xcf34('0x20')]?_0x56e8ec[_0xcf34('0x20')][_0xcf34('0x22')]||null:null})[_0xcf34('0x12')](function(_0x4a305b){if(_0x4a305b){return _0x4a305b[_0xcf34('0x28')](_0x56e8ec[_0xcf34('0x1f')][_0xcf34('0x29')],_[_0xcf34('0x2a')](_0x56e8ec[_0xcf34('0x1f')],[_0xcf34('0x29'),'id'])||{});}})[_0xcf34('0x2b')](function(_0x1483c3){logger[_0xcf34('0x13')](_0xcf34('0x2c'),_0x56e8ec);logger[_0xcf34('0x15')](_0xcf34('0x2c'),_0x56e8ec,JSON[_0xcf34('0x25')](_0x1483c3));_0x142954(_0x1483c3);})[_0xcf34('0x1c')](function(_0x18f26a){logger[_0xcf34('0x17')]('AddTags',_0x18f26a[_0xcf34('0x1a')],_0x56e8ec);_0x15f9a0(_this['error'](0x1f4,_0x18f26a['message']));});});};