82729123f7908091dedfb4c220d94f60aea2d9d1
[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 _0xf630=['info','catch','UpdateMailApplication','MailApplication','update','body','options','raw','limit','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','MailApplication,\x20%s,\x20%s','request\x20sent','debug','MailApplication,\x20%s,\x20%s,\x20%s','stringify','error','code','message'];(function(_0x42cae2,_0x284ef8){var _0x5f256f=function(_0x41abc8){while(--_0x41abc8){_0x42cae2['push'](_0x42cae2['shift']());}};_0x5f256f(++_0x284ef8);}(_0xf630,0xf0));var _0x0f63=function(_0x238281,_0x2e4cd0){_0x238281=_0x238281-0x0;var _0x22c358=_0xf630[_0x238281];return _0x22c358;};'use strict';var _=require(_0x0f63('0x0'));var util=require(_0x0f63('0x1'));var moment=require(_0x0f63('0x2'));var BPromise=require(_0x0f63('0x3'));var rs=require(_0x0f63('0x4'));var fs=require('fs');var Redis=require(_0x0f63('0x5'));var db=require(_0x0f63('0x6'))['db'];var utils=require(_0x0f63('0x7'));var logger=require(_0x0f63('0x8'))(_0x0f63('0x9'));var config=require(_0x0f63('0xa'));var jayson=require(_0x0f63('0xb'));var client=jayson[_0x0f63('0xc')][_0x0f63('0xd')]({'port':0x232a});function respondWithRpcPromise(_0x39e858,_0x56f48f,_0x59deb6){return new BPromise(function(_0x3e4b52,_0x3f1981){return client[_0x0f63('0xe')](_0x39e858,_0x59deb6)[_0x0f63('0xf')](function(_0x16713d){logger['info'](_0x0f63('0x10'),_0x56f48f,_0x0f63('0x11'));logger[_0x0f63('0x12')](_0x0f63('0x13'),_0x56f48f,_0x0f63('0x11'),JSON[_0x0f63('0x14')](_0x16713d));if(_0x16713d[_0x0f63('0x15')]){if(_0x16713d[_0x0f63('0x15')][_0x0f63('0x16')]===0x1f4){logger[_0x0f63('0x15')]('MailApplication,\x20%s,\x20%s',_0x56f48f,_0x16713d['error'][_0x0f63('0x17')]);return _0x3f1981(_0x16713d['error'][_0x0f63('0x17')]);}logger['error'](_0x0f63('0x10'),_0x56f48f,_0x16713d[_0x0f63('0x15')][_0x0f63('0x17')]);return _0x3e4b52(_0x16713d[_0x0f63('0x15')][_0x0f63('0x17')]);}else{logger[_0x0f63('0x18')]('MailApplication,\x20%s,\x20%s',_0x56f48f,_0x0f63('0x11'));_0x3e4b52(_0x16713d['result'][_0x0f63('0x17')]);}})[_0x0f63('0x19')](function(_0x35f4a7){logger[_0x0f63('0x15')](_0x0f63('0x10'),_0x56f48f,_0x35f4a7);_0x3f1981(_0x35f4a7);});});}exports[_0x0f63('0x1a')]=function(_0x42d363){var _0x39caef=this;return new Promise(function(_0x4470b2,_0x1495b8){return db[_0x0f63('0x1b')][_0x0f63('0x1c')](_0x42d363[_0x0f63('0x1d')],{'raw':_0x42d363[_0x0f63('0x1e')]?_0x42d363[_0x0f63('0x1e')][_0x0f63('0x1f')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x42d363[_0x0f63('0x1e')]?_0x42d363[_0x0f63('0x1e')]['where']||null:null,'attributes':_0x42d363[_0x0f63('0x1e')]?_0x42d363['options']['attributes']||null:null,'limit':_0x42d363[_0x0f63('0x1e')]?_0x42d363[_0x0f63('0x1e')][_0x0f63('0x20')]||null:null})[_0x0f63('0xf')](function(_0x365f73){logger[_0x0f63('0x18')](_0x0f63('0x1a'),_0x42d363);logger[_0x0f63('0x12')]('UpdateMailApplication',_0x42d363,JSON['stringify'](_0x365f73));_0x4470b2(_0x365f73);})['catch'](function(_0x23f754){logger[_0x0f63('0x15')]('UpdateMailApplication',_0x23f754[_0x0f63('0x17')],_0x42d363);_0x1495b8(_0x39caef[_0x0f63('0x15')](0x1f4,_0x23f754[_0x0f63('0x17')]));});});};