36365551ab472e4867514b2c41a65618300e222d
[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 _0xaa2e=['info','MailApplication,\x20%s,\x20%s','request\x20sent','debug','MailApplication,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','body','options','raw','where','UpdateMailApplication','stringify','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','request','then'];(function(_0x5d3010,_0x36c76b){var _0x35eb61=function(_0x2dc43c){while(--_0x2dc43c){_0x5d3010['push'](_0x5d3010['shift']());}};_0x35eb61(++_0x36c76b);}(_0xaa2e,0x6d));var _0xeaa2=function(_0xd9cc02,_0x3a3b89){_0xd9cc02=_0xd9cc02-0x0;var _0x136327=_0xaa2e[_0xd9cc02];return _0x136327;};'use strict';var _=require(_0xeaa2('0x0'));var util=require(_0xeaa2('0x1'));var moment=require(_0xeaa2('0x2'));var BPromise=require(_0xeaa2('0x3'));var rs=require(_0xeaa2('0x4'));var fs=require('fs');var Redis=require(_0xeaa2('0x5'));var db=require(_0xeaa2('0x6'))['db'];var utils=require(_0xeaa2('0x7'));var logger=require(_0xeaa2('0x8'))(_0xeaa2('0x9'));var config=require(_0xeaa2('0xa'));var jayson=require(_0xeaa2('0xb'));var client=jayson[_0xeaa2('0xc')]['http']({'port':0x232a});function respondWithRpcPromise(_0x373fcb,_0x5bacc1,_0x6fb8a8){return new BPromise(function(_0x2f80d5,_0x39f194){return client[_0xeaa2('0xd')](_0x373fcb,_0x6fb8a8)[_0xeaa2('0xe')](function(_0x2d366d){logger[_0xeaa2('0xf')](_0xeaa2('0x10'),_0x5bacc1,_0xeaa2('0x11'));logger[_0xeaa2('0x12')](_0xeaa2('0x13'),_0x5bacc1,'request\x20sent',JSON['stringify'](_0x2d366d));if(_0x2d366d[_0xeaa2('0x14')]){if(_0x2d366d[_0xeaa2('0x14')][_0xeaa2('0x15')]===0x1f4){logger['error']('MailApplication,\x20%s,\x20%s',_0x5bacc1,_0x2d366d['error'][_0xeaa2('0x16')]);return _0x39f194(_0x2d366d['error'][_0xeaa2('0x16')]);}logger[_0xeaa2('0x14')]('MailApplication,\x20%s,\x20%s',_0x5bacc1,_0x2d366d['error'][_0xeaa2('0x16')]);return _0x2f80d5(_0x2d366d[_0xeaa2('0x14')][_0xeaa2('0x16')]);}else{logger['info']('MailApplication,\x20%s,\x20%s',_0x5bacc1,'request\x20sent');_0x2f80d5(_0x2d366d[_0xeaa2('0x17')][_0xeaa2('0x16')]);}})[_0xeaa2('0x18')](function(_0x3407c7){logger[_0xeaa2('0x14')](_0xeaa2('0x10'),_0x5bacc1,_0x3407c7);_0x39f194(_0x3407c7);});});}exports['UpdateMailApplication']=function(_0xeb2ca2){var _0x34bed9=this;return new Promise(function(_0x524662,_0x43c043){return db['MailApplication']['update'](_0xeb2ca2[_0xeaa2('0x19')],{'raw':_0xeb2ca2['options']?_0xeb2ca2[_0xeaa2('0x1a')][_0xeaa2('0x1b')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0xeb2ca2['options']?_0xeb2ca2[_0xeaa2('0x1a')][_0xeaa2('0x1c')]||null:null,'attributes':_0xeb2ca2['options']?_0xeb2ca2[_0xeaa2('0x1a')]['attributes']||null:null,'limit':_0xeb2ca2['options']?_0xeb2ca2[_0xeaa2('0x1a')]['limit']||null:null})[_0xeaa2('0xe')](function(_0x3a97ca){logger[_0xeaa2('0xf')](_0xeaa2('0x1d'),_0xeb2ca2);logger['debug'](_0xeaa2('0x1d'),_0xeb2ca2,JSON[_0xeaa2('0x1e')](_0x3a97ca));_0x524662(_0x3a97ca);})[_0xeaa2('0x18')](function(_0x25715f){logger[_0xeaa2('0x14')](_0xeaa2('0x1d'),_0x25715f['message'],_0xeb2ca2);_0x43c043(_0x34bed9['error'](0x1f4,_0x25715f[_0xeaa2('0x16')]));});});};