Built motion from commit a61a4a20.|2.5.46
[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 _0xca6e=['util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','http','defaults','redis','localhost','./faxInteraction.socket','register','request','then','info','FaxInteraction,\x20%s,\x20%s','debug','FaxInteraction,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','catch','UpdateFaxInteraction','FaxInteraction','update','body','options','raw','where','attributes','limit','AddTagsToFaxInteraction','find','addTags','ids','spread','AddTags'];(function(_0x40c3ca,_0x4a0af9){var _0x471e52=function(_0x1d341a){while(--_0x1d341a){_0x40c3ca['push'](_0x40c3ca['shift']());}};_0x471e52(++_0x4a0af9);}(_0xca6e,0x19a));var _0xeca6=function(_0x44dccb,_0x3bdd89){_0x44dccb=_0x44dccb-0x0;var _0x498391=_0xca6e[_0x44dccb];return _0x498391;};'use strict';var _=require('lodash');var util=require(_0xeca6('0x0'));var moment=require(_0xeca6('0x1'));var BPromise=require(_0xeca6('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xeca6('0x3'));var db=require(_0xeca6('0x4'))['db'];var utils=require(_0xeca6('0x5'));var logger=require('../../config/logger')(_0xeca6('0x6'));var config=require(_0xeca6('0x7'));var jayson=require('jayson/promise');var client=jayson['client'][_0xeca6('0x8')]({'port':0x232a});config['redis']=_[_0xeca6('0x9')](config[_0xeca6('0xa')],{'host':_0xeca6('0xb'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xeca6('0xa')]));require(_0xeca6('0xc'))[_0xeca6('0xd')](socket);function respondWithRpcPromise(_0x328dc4,_0x1ade8d,_0x113311){return new BPromise(function(_0x5261ff,_0x1ae886){return client[_0xeca6('0xe')](_0x328dc4,_0x113311)[_0xeca6('0xf')](function(_0x5ac656){logger[_0xeca6('0x10')](_0xeca6('0x11'),_0x1ade8d,'request\x20sent');logger[_0xeca6('0x12')](_0xeca6('0x13'),_0x1ade8d,_0xeca6('0x14'),JSON[_0xeca6('0x15')](_0x5ac656));if(_0x5ac656[_0xeca6('0x16')]){if(_0x5ac656[_0xeca6('0x16')][_0xeca6('0x17')]===0x1f4){logger['error']('FaxInteraction,\x20%s,\x20%s',_0x1ade8d,_0x5ac656[_0xeca6('0x16')]['message']);return _0x1ae886(_0x5ac656[_0xeca6('0x16')]['message']);}logger[_0xeca6('0x16')]('FaxInteraction,\x20%s,\x20%s',_0x1ade8d,_0x5ac656['error'][_0xeca6('0x18')]);return _0x5261ff(_0x5ac656[_0xeca6('0x16')][_0xeca6('0x18')]);}else{logger[_0xeca6('0x10')]('FaxInteraction,\x20%s,\x20%s',_0x1ade8d,'request\x20sent');_0x5261ff(_0x5ac656['result'][_0xeca6('0x18')]);}})[_0xeca6('0x19')](function(_0x2f8240){logger['error'](_0xeca6('0x11'),_0x1ade8d,_0x2f8240);_0x1ae886(_0x2f8240);});});}exports[_0xeca6('0x1a')]=function(_0x495e4b){var _0x1621ed=this;return new Promise(function(_0x2dc2d5,_0x148152){return db[_0xeca6('0x1b')][_0xeca6('0x1c')](_0x495e4b[_0xeca6('0x1d')],{'raw':_0x495e4b['options']?_0x495e4b[_0xeca6('0x1e')][_0xeca6('0x1f')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x495e4b[_0xeca6('0x1e')]?_0x495e4b['options'][_0xeca6('0x20')]||null:null,'attributes':_0x495e4b[_0xeca6('0x1e')]?_0x495e4b[_0xeca6('0x1e')][_0xeca6('0x21')]||null:null,'limit':_0x495e4b['options']?_0x495e4b[_0xeca6('0x1e')][_0xeca6('0x22')]||null:null})['then'](function(_0x1c0833){logger[_0xeca6('0x10')](_0xeca6('0x1a'),_0x495e4b);logger[_0xeca6('0x12')](_0xeca6('0x1a'),_0x495e4b,JSON['stringify'](_0x1c0833));_0x2dc2d5(_0x1c0833);})[_0xeca6('0x19')](function(_0x2b15af){logger['error'](_0xeca6('0x1a'),_0x2b15af[_0xeca6('0x18')],_0x495e4b);_0x148152(_0x1621ed['error'](0x1f4,_0x2b15af['message']));});});};exports[_0xeca6('0x23')]=function(_0x544124){return new Promise(function(_0xf73d89,_0x46e6aa){return db[_0xeca6('0x1b')][_0xeca6('0x24')]({'where':_0x544124[_0xeca6('0x1e')]?_0x544124['options']['where']||null:null})[_0xeca6('0xf')](function(_0x332120){if(_0x332120){return _0x332120[_0xeca6('0x25')](_0x544124['body'][_0xeca6('0x26')],_['omit'](_0x544124[_0xeca6('0x1d')],[_0xeca6('0x26'),'id'])||{});}})[_0xeca6('0x27')](function(_0x2621d7){logger[_0xeca6('0x10')](_0xeca6('0x28'),_0x544124);logger['debug'](_0xeca6('0x28'),_0x544124,JSON[_0xeca6('0x15')](_0x2621d7));_0xf73d89(_0x2621d7);})[_0xeca6('0x19')](function(_0xf74ff){logger['error']('AddTags',_0xf74ff[_0xeca6('0x18')],_0x544124);_0x46e6aa(_this[_0xeca6('0x16')](0x1f4,_0xf74ff['message']));});});};