a612bafb40abb1c778b1185573ccbbdb4d182fa6
[motion2.git] / server / api / mailApplication / mailApplication.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 _0x69b3=['util','moment','randomstring','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','request','info','request\x20sent','debug','MailApplication,\x20%s,\x20%s,\x20%s','stringify','error','code','MailApplication,\x20%s,\x20%s','message','result','catch','UpdateMailApplication','MailApplication','update','body','options','raw','where','attributes','limit','then'];(function(_0x288929,_0x308ade){var _0x37b91c=function(_0x2f78f7){while(--_0x2f78f7){_0x288929['push'](_0x288929['shift']());}};_0x37b91c(++_0x308ade);}(_0x69b3,0xe0));var _0x369b=function(_0xb1eaac,_0x5db827){_0xb1eaac=_0xb1eaac-0x0;var _0x106d0b=_0x69b3[_0xb1eaac];return _0x106d0b;};'use strict';var _=require('lodash');var util=require(_0x369b('0x0'));var moment=require(_0x369b('0x1'));var BPromise=require('bluebird');var rs=require(_0x369b('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x369b('0x3'))['db'];var utils=require(_0x369b('0x4'));var logger=require('../../config/logger')(_0x369b('0x5'));var config=require(_0x369b('0x6'));var jayson=require(_0x369b('0x7'));var client=jayson[_0x369b('0x8')][_0x369b('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x3b91b6,_0x3b3e1c,_0x222a26){return new BPromise(function(_0x27809d,_0x20fd30){return client[_0x369b('0xa')](_0x3b91b6,_0x222a26)['then'](function(_0x4a5027){logger[_0x369b('0xb')]('MailApplication,\x20%s,\x20%s',_0x3b3e1c,_0x369b('0xc'));logger[_0x369b('0xd')](_0x369b('0xe'),_0x3b3e1c,_0x369b('0xc'),JSON[_0x369b('0xf')](_0x4a5027));if(_0x4a5027['error']){if(_0x4a5027[_0x369b('0x10')][_0x369b('0x11')]===0x1f4){logger[_0x369b('0x10')](_0x369b('0x12'),_0x3b3e1c,_0x4a5027[_0x369b('0x10')][_0x369b('0x13')]);return _0x20fd30(_0x4a5027[_0x369b('0x10')]['message']);}logger[_0x369b('0x10')](_0x369b('0x12'),_0x3b3e1c,_0x4a5027['error']['message']);return _0x27809d(_0x4a5027['error'][_0x369b('0x13')]);}else{logger[_0x369b('0xb')](_0x369b('0x12'),_0x3b3e1c,_0x369b('0xc'));_0x27809d(_0x4a5027[_0x369b('0x14')][_0x369b('0x13')]);}})[_0x369b('0x15')](function(_0x4b07ef){logger[_0x369b('0x10')]('MailApplication,\x20%s,\x20%s',_0x3b3e1c,_0x4b07ef);_0x20fd30(_0x4b07ef);});});}exports[_0x369b('0x16')]=function(_0x1daee5){var _0x2d9469=this;return new Promise(function(_0x577321,_0x35c92c){return db[_0x369b('0x17')][_0x369b('0x18')](_0x1daee5[_0x369b('0x19')],{'raw':_0x1daee5[_0x369b('0x1a')]?_0x1daee5[_0x369b('0x1a')][_0x369b('0x1b')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x1daee5[_0x369b('0x1a')]?_0x1daee5[_0x369b('0x1a')][_0x369b('0x1c')]||null:null,'attributes':_0x1daee5['options']?_0x1daee5[_0x369b('0x1a')][_0x369b('0x1d')]||null:null,'limit':_0x1daee5[_0x369b('0x1a')]?_0x1daee5[_0x369b('0x1a')][_0x369b('0x1e')]||null:null})[_0x369b('0x1f')](function(_0x51a944){logger[_0x369b('0xb')]('UpdateMailApplication',_0x1daee5);logger[_0x369b('0xd')](_0x369b('0x16'),_0x1daee5,JSON[_0x369b('0xf')](_0x51a944));_0x577321(_0x51a944);})[_0x369b('0x15')](function(_0x326893){logger[_0x369b('0x10')](_0x369b('0x16'),_0x326893[_0x369b('0x13')],_0x1daee5);_0x35c92c(_0x2d9469['error'](0x1f4,_0x326893[_0x369b('0x13')]));});});};