b5f6f663fd6a44a2794740f13e104bb99bcf80ef
[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 _0x8236=['defaults','request','then','info','request\x20sent','FaxInteraction,\x20%s,\x20%s,\x20%s','stringify','error','code','FaxInteraction,\x20%s,\x20%s','message','result','catch','UpdateFaxInteraction','FaxInteraction','update','body','options','raw','where','attributes','limit','debug','AddTagsToFaxInteraction','addTags','ids','omit','AddTags','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','jayson/promise','redis'];(function(_0x3b9573,_0x53968a){var _0x318162=function(_0x997478){while(--_0x997478){_0x3b9573['push'](_0x3b9573['shift']());}};_0x318162(++_0x53968a);}(_0x8236,0xb0));var _0x6823=function(_0x51c819,_0xd812db){_0x51c819=_0x51c819-0x0;var _0x15c5d2=_0x8236[_0x51c819];return _0x15c5d2;};'use strict';var _=require(_0x6823('0x0'));var util=require(_0x6823('0x1'));var moment=require('moment');var BPromise=require(_0x6823('0x2'));var rs=require(_0x6823('0x3'));var fs=require('fs');var Redis=require(_0x6823('0x4'));var db=require(_0x6823('0x5'))['db'];var utils=require(_0x6823('0x6'));var logger=require('../../config/logger')('rpc');var config=require('../../config/environment');var jayson=require(_0x6823('0x7'));var client=jayson['client']['http']({'port':0x232a});config[_0x6823('0x8')]=_[_0x6823('0x9')](config[_0x6823('0x8')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x6823('0x8')]));require('./faxInteraction.socket')['register'](socket);function respondWithRpcPromise(_0x55b663,_0xbe81b9,_0x5852a4){return new BPromise(function(_0xe17d50,_0x21e912){return client[_0x6823('0xa')](_0x55b663,_0x5852a4)[_0x6823('0xb')](function(_0x10988c){logger[_0x6823('0xc')]('FaxInteraction,\x20%s,\x20%s',_0xbe81b9,_0x6823('0xd'));logger['debug'](_0x6823('0xe'),_0xbe81b9,_0x6823('0xd'),JSON[_0x6823('0xf')](_0x10988c));if(_0x10988c['error']){if(_0x10988c[_0x6823('0x10')][_0x6823('0x11')]===0x1f4){logger['error'](_0x6823('0x12'),_0xbe81b9,_0x10988c[_0x6823('0x10')][_0x6823('0x13')]);return _0x21e912(_0x10988c[_0x6823('0x10')][_0x6823('0x13')]);}logger['error']('FaxInteraction,\x20%s,\x20%s',_0xbe81b9,_0x10988c[_0x6823('0x10')][_0x6823('0x13')]);return _0xe17d50(_0x10988c[_0x6823('0x10')][_0x6823('0x13')]);}else{logger[_0x6823('0xc')]('FaxInteraction,\x20%s,\x20%s',_0xbe81b9,_0x6823('0xd'));_0xe17d50(_0x10988c[_0x6823('0x14')][_0x6823('0x13')]);}})[_0x6823('0x15')](function(_0x42c48b){logger['error'](_0x6823('0x12'),_0xbe81b9,_0x42c48b);_0x21e912(_0x42c48b);});});}exports[_0x6823('0x16')]=function(_0x5a6e2c){var _0x54d869=this;return new Promise(function(_0x44ddcb,_0x5720b5){return db[_0x6823('0x17')][_0x6823('0x18')](_0x5a6e2c[_0x6823('0x19')],{'raw':_0x5a6e2c[_0x6823('0x1a')]?_0x5a6e2c['options'][_0x6823('0x1b')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x5a6e2c[_0x6823('0x1a')]?_0x5a6e2c[_0x6823('0x1a')][_0x6823('0x1c')]||null:null,'attributes':_0x5a6e2c['options']?_0x5a6e2c['options'][_0x6823('0x1d')]||null:null,'limit':_0x5a6e2c[_0x6823('0x1a')]?_0x5a6e2c['options'][_0x6823('0x1e')]||null:null})[_0x6823('0xb')](function(_0x53352a){logger[_0x6823('0xc')](_0x6823('0x16'),_0x5a6e2c);logger[_0x6823('0x1f')](_0x6823('0x16'),_0x5a6e2c,JSON[_0x6823('0xf')](_0x53352a));_0x44ddcb(_0x53352a);})[_0x6823('0x15')](function(_0x5277fe){logger[_0x6823('0x10')]('UpdateFaxInteraction',_0x5277fe[_0x6823('0x13')],_0x5a6e2c);_0x5720b5(_0x54d869[_0x6823('0x10')](0x1f4,_0x5277fe[_0x6823('0x13')]));});});};exports[_0x6823('0x20')]=function(_0x31915b){return new Promise(function(_0x496cef,_0x40b516){return db['FaxInteraction']['find']({'where':_0x31915b[_0x6823('0x1a')]?_0x31915b[_0x6823('0x1a')]['where']||null:null})[_0x6823('0xb')](function(_0x436c46){if(_0x436c46){return _0x436c46[_0x6823('0x21')](_0x31915b[_0x6823('0x19')][_0x6823('0x22')],_[_0x6823('0x23')](_0x31915b[_0x6823('0x19')],['ids','id'])||{});}})['spread'](function(_0x2211b0){logger['info'](_0x6823('0x24'),_0x31915b);logger[_0x6823('0x1f')](_0x6823('0x24'),_0x31915b,JSON[_0x6823('0xf')](_0x2211b0));_0x496cef(_0x2211b0);})[_0x6823('0x15')](function(_0x7c83d2){logger['error'](_0x6823('0x24'),_0x7c83d2[_0x6823('0x13')],_0x31915b);_0x40b516(_this[_0x6823('0x10')](0x1f4,_0x7c83d2[_0x6823('0x13')]));});});};