61800ac3e82ef03f924edfeb25b7bdf541c2f281
[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 _0x7090=['FaxInteraction','update','options','raw','where','attributes','limit','AddTagsToFaxInteraction','find','addTags','body','ids','spread','AddTags','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./faxInteraction.socket','then','request\x20sent','debug','FaxInteraction,\x20%s,\x20%s,\x20%s','stringify','error','FaxInteraction,\x20%s,\x20%s','message','info','catch','UpdateFaxInteraction'];(function(_0x255d9f,_0x558dbf){var _0x435eb4=function(_0x3ca94d){while(--_0x3ca94d){_0x255d9f['push'](_0x255d9f['shift']());}};_0x435eb4(++_0x558dbf);}(_0x7090,0xbe));var _0x0709=function(_0x235f49,_0x2992b4){_0x235f49=_0x235f49-0x0;var _0x551139=_0x7090[_0x235f49];return _0x551139;};'use strict';var _=require(_0x0709('0x0'));var util=require(_0x0709('0x1'));var moment=require(_0x0709('0x2'));var BPromise=require(_0x0709('0x3'));var rs=require(_0x0709('0x4'));var fs=require('fs');var Redis=require(_0x0709('0x5'));var db=require(_0x0709('0x6'))['db'];var utils=require(_0x0709('0x7'));var logger=require(_0x0709('0x8'))(_0x0709('0x9'));var config=require(_0x0709('0xa'));var jayson=require(_0x0709('0xb'));var client=jayson[_0x0709('0xc')][_0x0709('0xd')]({'port':0x232a});config[_0x0709('0xe')]=_[_0x0709('0xf')](config[_0x0709('0xe')],{'host':_0x0709('0x10'),'port':0x18eb});var socket=require(_0x0709('0x11'))(new Redis(config[_0x0709('0xe')]));require(_0x0709('0x12'))['register'](socket);function respondWithRpcPromise(_0x474470,_0x1bb7ab,_0x108e35){return new BPromise(function(_0x13a26e,_0x3dab00){return client['request'](_0x474470,_0x108e35)[_0x0709('0x13')](function(_0x582232){logger['info']('FaxInteraction,\x20%s,\x20%s',_0x1bb7ab,_0x0709('0x14'));logger[_0x0709('0x15')](_0x0709('0x16'),_0x1bb7ab,'request\x20sent',JSON[_0x0709('0x17')](_0x582232));if(_0x582232[_0x0709('0x18')]){if(_0x582232[_0x0709('0x18')]['code']===0x1f4){logger[_0x0709('0x18')](_0x0709('0x19'),_0x1bb7ab,_0x582232[_0x0709('0x18')][_0x0709('0x1a')]);return _0x3dab00(_0x582232['error'][_0x0709('0x1a')]);}logger['error']('FaxInteraction,\x20%s,\x20%s',_0x1bb7ab,_0x582232[_0x0709('0x18')][_0x0709('0x1a')]);return _0x13a26e(_0x582232['error'][_0x0709('0x1a')]);}else{logger[_0x0709('0x1b')]('FaxInteraction,\x20%s,\x20%s',_0x1bb7ab,_0x0709('0x14'));_0x13a26e(_0x582232['result'][_0x0709('0x1a')]);}})[_0x0709('0x1c')](function(_0x574eb8){logger[_0x0709('0x18')](_0x0709('0x19'),_0x1bb7ab,_0x574eb8);_0x3dab00(_0x574eb8);});});}exports[_0x0709('0x1d')]=function(_0x10fafc){var _0x1fc18e=this;return new Promise(function(_0x191e69,_0xe670ac){return db[_0x0709('0x1e')][_0x0709('0x1f')](_0x10fafc['body'],{'raw':_0x10fafc[_0x0709('0x20')]?_0x10fafc[_0x0709('0x20')][_0x0709('0x21')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x10fafc['options']?_0x10fafc[_0x0709('0x20')][_0x0709('0x22')]||null:null,'attributes':_0x10fafc[_0x0709('0x20')]?_0x10fafc['options'][_0x0709('0x23')]||null:null,'limit':_0x10fafc[_0x0709('0x20')]?_0x10fafc[_0x0709('0x20')][_0x0709('0x24')]||null:null})[_0x0709('0x13')](function(_0x253912){logger[_0x0709('0x1b')]('UpdateFaxInteraction',_0x10fafc);logger[_0x0709('0x15')]('UpdateFaxInteraction',_0x10fafc,JSON[_0x0709('0x17')](_0x253912));_0x191e69(_0x253912);})[_0x0709('0x1c')](function(_0x3c866b){logger[_0x0709('0x18')](_0x0709('0x1d'),_0x3c866b['message'],_0x10fafc);_0xe670ac(_0x1fc18e[_0x0709('0x18')](0x1f4,_0x3c866b['message']));});});};exports[_0x0709('0x25')]=function(_0x219b64){return new Promise(function(_0x5601f5,_0x40e773){return db['FaxInteraction'][_0x0709('0x26')]({'where':_0x219b64[_0x0709('0x20')]?_0x219b64[_0x0709('0x20')][_0x0709('0x22')]||null:null})[_0x0709('0x13')](function(_0x58f7fe){if(_0x58f7fe){return _0x58f7fe[_0x0709('0x27')](_0x219b64[_0x0709('0x28')][_0x0709('0x29')],_['omit'](_0x219b64[_0x0709('0x28')],[_0x0709('0x29'),'id'])||{});}})[_0x0709('0x2a')](function(_0x3b27fd){logger[_0x0709('0x1b')](_0x0709('0x2b'),_0x219b64);logger[_0x0709('0x15')](_0x0709('0x2b'),_0x219b64,JSON[_0x0709('0x17')](_0x3b27fd));_0x5601f5(_0x3b27fd);})[_0x0709('0x1c')](function(_0x389d8c){logger[_0x0709('0x18')](_0x0709('0x2b'),_0x389d8c[_0x0709('0x1a')],_0x219b64);_0x40e773(_this[_0x0709('0x18')](0x1f4,_0x389d8c[_0x0709('0x1a')]));});});};