57d14f81f137b716c8b626776ccb13e2ef6bfd92
[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 _0x1b10=['../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','redis','./faxInteraction.socket','register','request','then','info','request\x20sent','debug','stringify','error','code','message','FaxInteraction,\x20%s,\x20%s','catch','UpdateFaxInteraction','FaxInteraction','update','options','raw','limit','AddTagsToFaxInteraction','find','where','addTags','body','ids','spread','AddTags','lodash','util','bluebird','ioredis'];(function(_0x47924f,_0x116749){var _0x2b6274=function(_0x39ab68){while(--_0x39ab68){_0x47924f['push'](_0x47924f['shift']());}};_0x2b6274(++_0x116749);}(_0x1b10,0xe0));var _0x01b1=function(_0x83fc12,_0x474345){_0x83fc12=_0x83fc12-0x0;var _0x1e50d3=_0x1b10[_0x83fc12];return _0x1e50d3;};'use strict';var _=require(_0x01b1('0x0'));var util=require(_0x01b1('0x1'));var moment=require('moment');var BPromise=require(_0x01b1('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x01b1('0x3'));var db=require(_0x01b1('0x4'))['db'];var utils=require(_0x01b1('0x5'));var logger=require(_0x01b1('0x6'))(_0x01b1('0x7'));var config=require('../../config/environment');var jayson=require(_0x01b1('0x8'));var client=jayson[_0x01b1('0x9')]['http']({'port':0x232a});config[_0x01b1('0xa')]=_['defaults'](config[_0x01b1('0xa')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x01b1('0xa')]));require(_0x01b1('0xb'))[_0x01b1('0xc')](socket);function respondWithRpcPromise(_0x5a0247,_0x5c944a,_0x1347be){return new BPromise(function(_0x22b5ce,_0x3c41eb){return client[_0x01b1('0xd')](_0x5a0247,_0x1347be)[_0x01b1('0xe')](function(_0x4d8373){logger[_0x01b1('0xf')]('FaxInteraction,\x20%s,\x20%s',_0x5c944a,_0x01b1('0x10'));logger[_0x01b1('0x11')]('FaxInteraction,\x20%s,\x20%s,\x20%s',_0x5c944a,_0x01b1('0x10'),JSON[_0x01b1('0x12')](_0x4d8373));if(_0x4d8373[_0x01b1('0x13')]){if(_0x4d8373[_0x01b1('0x13')][_0x01b1('0x14')]===0x1f4){logger[_0x01b1('0x13')]('FaxInteraction,\x20%s,\x20%s',_0x5c944a,_0x4d8373[_0x01b1('0x13')][_0x01b1('0x15')]);return _0x3c41eb(_0x4d8373[_0x01b1('0x13')][_0x01b1('0x15')]);}logger[_0x01b1('0x13')](_0x01b1('0x16'),_0x5c944a,_0x4d8373[_0x01b1('0x13')]['message']);return _0x22b5ce(_0x4d8373['error']['message']);}else{logger[_0x01b1('0xf')]('FaxInteraction,\x20%s,\x20%s',_0x5c944a,_0x01b1('0x10'));_0x22b5ce(_0x4d8373['result'][_0x01b1('0x15')]);}})[_0x01b1('0x17')](function(_0x214cd5){logger[_0x01b1('0x13')](_0x01b1('0x16'),_0x5c944a,_0x214cd5);_0x3c41eb(_0x214cd5);});});}exports[_0x01b1('0x18')]=function(_0x4332d9){var _0x5d4e8d=this;return new Promise(function(_0x791130,_0x1417b0){return db[_0x01b1('0x19')][_0x01b1('0x1a')](_0x4332d9['body'],{'raw':_0x4332d9[_0x01b1('0x1b')]?_0x4332d9[_0x01b1('0x1b')][_0x01b1('0x1c')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x4332d9[_0x01b1('0x1b')]?_0x4332d9[_0x01b1('0x1b')]['where']||null:null,'attributes':_0x4332d9['options']?_0x4332d9[_0x01b1('0x1b')]['attributes']||null:null,'limit':_0x4332d9[_0x01b1('0x1b')]?_0x4332d9[_0x01b1('0x1b')][_0x01b1('0x1d')]||null:null})[_0x01b1('0xe')](function(_0x1d3719){logger['info']('UpdateFaxInteraction',_0x4332d9);logger['debug'](_0x01b1('0x18'),_0x4332d9,JSON[_0x01b1('0x12')](_0x1d3719));_0x791130(_0x1d3719);})[_0x01b1('0x17')](function(_0x44ef10){logger['error'](_0x01b1('0x18'),_0x44ef10['message'],_0x4332d9);_0x1417b0(_0x5d4e8d[_0x01b1('0x13')](0x1f4,_0x44ef10['message']));});});};exports[_0x01b1('0x1e')]=function(_0x48a282){return new Promise(function(_0x2c01f9,_0xdf773){return db[_0x01b1('0x19')][_0x01b1('0x1f')]({'where':_0x48a282[_0x01b1('0x1b')]?_0x48a282[_0x01b1('0x1b')][_0x01b1('0x20')]||null:null})[_0x01b1('0xe')](function(_0x480aa9){if(_0x480aa9){return _0x480aa9[_0x01b1('0x21')](_0x48a282[_0x01b1('0x22')][_0x01b1('0x23')],_['omit'](_0x48a282[_0x01b1('0x22')],[_0x01b1('0x23'),'id'])||{});}})[_0x01b1('0x24')](function(_0x32f6ec){logger[_0x01b1('0xf')](_0x01b1('0x25'),_0x48a282);logger[_0x01b1('0x11')](_0x01b1('0x25'),_0x48a282,JSON['stringify'](_0x32f6ec));_0x2c01f9(_0x32f6ec);})[_0x01b1('0x17')](function(_0x1ce190){logger['error']('AddTags',_0x1ce190['message'],_0x48a282);_0xdf773(_this['error'](0x1f4,_0x1ce190[_0x01b1('0x15')]));});});};