c1cbef553e9311cde516c4f46765e51c26ba5de3
[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 _0x577b=['randomstring','ioredis','../../config/utils','../../config/logger','rpc','jayson/promise','client','request','then','info','debug','MailApplication,\x20%s,\x20%s,\x20%s','stringify','error','code','message','MailApplication,\x20%s,\x20%s','request\x20sent','result','catch','UpdateMailApplication','MailApplication','update','body','options','limit','lodash','util','moment','bluebird'];(function(_0x3256a7,_0x4b8454){var _0x3a25bc=function(_0x1fe93d){while(--_0x1fe93d){_0x3256a7['push'](_0x3256a7['shift']());}};_0x3a25bc(++_0x4b8454);}(_0x577b,0xce));var _0xb577=function(_0x525c7b,_0x488fcc){_0x525c7b=_0x525c7b-0x0;var _0x27b33e=_0x577b[_0x525c7b];return _0x27b33e;};'use strict';var _=require(_0xb577('0x0'));var util=require(_0xb577('0x1'));var moment=require(_0xb577('0x2'));var BPromise=require(_0xb577('0x3'));var rs=require(_0xb577('0x4'));var fs=require('fs');var Redis=require(_0xb577('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0xb577('0x6'));var logger=require(_0xb577('0x7'))(_0xb577('0x8'));var config=require('../../config/environment');var jayson=require(_0xb577('0x9'));var client=jayson[_0xb577('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0x49b6ff,_0x2d21f1,_0x354e78){return new BPromise(function(_0x2e2cd2,_0x28ae16){return client[_0xb577('0xb')](_0x49b6ff,_0x354e78)[_0xb577('0xc')](function(_0x45d3bb){logger[_0xb577('0xd')]('MailApplication,\x20%s,\x20%s',_0x2d21f1,'request\x20sent');logger[_0xb577('0xe')](_0xb577('0xf'),_0x2d21f1,'request\x20sent',JSON[_0xb577('0x10')](_0x45d3bb));if(_0x45d3bb[_0xb577('0x11')]){if(_0x45d3bb['error'][_0xb577('0x12')]===0x1f4){logger[_0xb577('0x11')]('MailApplication,\x20%s,\x20%s',_0x2d21f1,_0x45d3bb[_0xb577('0x11')][_0xb577('0x13')]);return _0x28ae16(_0x45d3bb[_0xb577('0x11')]['message']);}logger['error'](_0xb577('0x14'),_0x2d21f1,_0x45d3bb[_0xb577('0x11')][_0xb577('0x13')]);return _0x2e2cd2(_0x45d3bb[_0xb577('0x11')][_0xb577('0x13')]);}else{logger['info'](_0xb577('0x14'),_0x2d21f1,_0xb577('0x15'));_0x2e2cd2(_0x45d3bb[_0xb577('0x16')]['message']);}})[_0xb577('0x17')](function(_0x53db12){logger[_0xb577('0x11')](_0xb577('0x14'),_0x2d21f1,_0x53db12);_0x28ae16(_0x53db12);});});}exports[_0xb577('0x18')]=function(_0x5db7b4){var _0x143979=this;return new Promise(function(_0x13c561,_0x11f2cf){return db[_0xb577('0x19')][_0xb577('0x1a')](_0x5db7b4[_0xb577('0x1b')],{'raw':_0x5db7b4[_0xb577('0x1c')]?_0x5db7b4[_0xb577('0x1c')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x5db7b4['options']?_0x5db7b4['options']['where']||null:null,'attributes':_0x5db7b4[_0xb577('0x1c')]?_0x5db7b4[_0xb577('0x1c')]['attributes']||null:null,'limit':_0x5db7b4[_0xb577('0x1c')]?_0x5db7b4[_0xb577('0x1c')][_0xb577('0x1d')]||null:null})[_0xb577('0xc')](function(_0x1824ab){logger[_0xb577('0xd')]('UpdateMailApplication',_0x5db7b4);logger[_0xb577('0xe')](_0xb577('0x18'),_0x5db7b4,JSON[_0xb577('0x10')](_0x1824ab));_0x13c561(_0x1824ab);})['catch'](function(_0x3e4d87){logger[_0xb577('0x11')](_0xb577('0x18'),_0x3e4d87[_0xb577('0x13')],_0x5db7b4);_0x11f2cf(_0x143979[_0xb577('0x11')](0x1f4,_0x3e4d87[_0xb577('0x13')]));});});};