162dcd2ebfe25ae3928201a2d456a5ea575542ed
[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 _0x7eb8=['request\x20sent','debug','MailApplication,\x20%s,\x20%s,\x20%s','stringify','error','code','message','MailApplication','body','options','raw','attributes','limit','UpdateMailApplication','catch','lodash','util','bluebird','randomstring','../../config/utils','../../config/logger','rpc','jayson/promise','client','then','info','MailApplication,\x20%s,\x20%s'];(function(_0x470e67,_0x4a596d){var _0x28bbde=function(_0x1bbf56){while(--_0x1bbf56){_0x470e67['push'](_0x470e67['shift']());}};_0x28bbde(++_0x4a596d);}(_0x7eb8,0x7b));var _0x87eb=function(_0x31c083,_0x2c7696){_0x31c083=_0x31c083-0x0;var _0x2436c2=_0x7eb8[_0x31c083];return _0x2436c2;};'use strict';var _=require(_0x87eb('0x0'));var util=require(_0x87eb('0x1'));var moment=require('moment');var BPromise=require(_0x87eb('0x2'));var rs=require(_0x87eb('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x87eb('0x4'));var logger=require(_0x87eb('0x5'))(_0x87eb('0x6'));var config=require('../../config/environment');var jayson=require(_0x87eb('0x7'));var client=jayson[_0x87eb('0x8')]['http']({'port':0x232a});function respondWithRpcPromise(_0x36d13e,_0x31ca01,_0x1ef8ce){return new BPromise(function(_0x5c4402,_0x504032){return client['request'](_0x36d13e,_0x1ef8ce)[_0x87eb('0x9')](function(_0x5d067a){logger[_0x87eb('0xa')](_0x87eb('0xb'),_0x31ca01,_0x87eb('0xc'));logger[_0x87eb('0xd')](_0x87eb('0xe'),_0x31ca01,_0x87eb('0xc'),JSON[_0x87eb('0xf')](_0x5d067a));if(_0x5d067a[_0x87eb('0x10')]){if(_0x5d067a['error'][_0x87eb('0x11')]===0x1f4){logger[_0x87eb('0x10')](_0x87eb('0xb'),_0x31ca01,_0x5d067a[_0x87eb('0x10')][_0x87eb('0x12')]);return _0x504032(_0x5d067a['error'][_0x87eb('0x12')]);}logger[_0x87eb('0x10')](_0x87eb('0xb'),_0x31ca01,_0x5d067a[_0x87eb('0x10')][_0x87eb('0x12')]);return _0x5c4402(_0x5d067a[_0x87eb('0x10')][_0x87eb('0x12')]);}else{logger[_0x87eb('0xa')]('MailApplication,\x20%s,\x20%s',_0x31ca01,_0x87eb('0xc'));_0x5c4402(_0x5d067a['result'][_0x87eb('0x12')]);}})['catch'](function(_0x56ab0d){logger[_0x87eb('0x10')]('MailApplication,\x20%s,\x20%s',_0x31ca01,_0x56ab0d);_0x504032(_0x56ab0d);});});}exports['UpdateMailApplication']=function(_0x572d39){var _0x470738=this;return new Promise(function(_0x45238c,_0x2494a1){return db[_0x87eb('0x13')]['update'](_0x572d39[_0x87eb('0x14')],{'raw':_0x572d39[_0x87eb('0x15')]?_0x572d39[_0x87eb('0x15')][_0x87eb('0x16')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x572d39['options']?_0x572d39[_0x87eb('0x15')]['where']||null:null,'attributes':_0x572d39['options']?_0x572d39[_0x87eb('0x15')][_0x87eb('0x17')]||null:null,'limit':_0x572d39[_0x87eb('0x15')]?_0x572d39[_0x87eb('0x15')][_0x87eb('0x18')]||null:null})[_0x87eb('0x9')](function(_0x33dbb5){logger[_0x87eb('0xa')](_0x87eb('0x19'),_0x572d39);logger[_0x87eb('0xd')](_0x87eb('0x19'),_0x572d39,JSON[_0x87eb('0xf')](_0x33dbb5));_0x45238c(_0x33dbb5);})[_0x87eb('0x1a')](function(_0x5a35ed){logger['error'](_0x87eb('0x19'),_0x5a35ed[_0x87eb('0x12')],_0x572d39);_0x2494a1(_0x470738[_0x87eb('0x10')](0x1f4,_0x5a35ed[_0x87eb('0x12')]));});});};