9c6f0af6666f236ecdb3267dffbd0a209c4ed3d2
[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 _0x4155=['options','where','limit','debug','stringify','lodash','util','bluebird','../../config/utils','../../config/environment','jayson/promise','client','http','request','then','info','MailApplication,\x20%s,\x20%s','MailApplication,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','message','result','catch','UpdateMailApplication','MailApplication','update','body'];(function(_0x4b5787,_0x2c5aa2){var _0x827b80=function(_0x4cbe14){while(--_0x4cbe14){_0x4b5787['push'](_0x4b5787['shift']());}};_0x827b80(++_0x2c5aa2);}(_0x4155,0x11d));var _0x5415=function(_0x428bbd,_0x28d713){_0x428bbd=_0x428bbd-0x0;var _0x1302c0=_0x4155[_0x428bbd];return _0x1302c0;};'use strict';var _=require(_0x5415('0x0'));var util=require(_0x5415('0x1'));var moment=require('moment');var BPromise=require(_0x5415('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x5415('0x3'));var logger=require('../../config/logger')('rpc');var config=require(_0x5415('0x4'));var jayson=require(_0x5415('0x5'));var client=jayson[_0x5415('0x6')][_0x5415('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x353599,_0x3c91ea,_0x3e2364){return new BPromise(function(_0x20ed1b,_0x5b0a3b){return client[_0x5415('0x8')](_0x353599,_0x3e2364)[_0x5415('0x9')](function(_0x448b4f){logger[_0x5415('0xa')](_0x5415('0xb'),_0x3c91ea,'request\x20sent');logger['debug'](_0x5415('0xc'),_0x3c91ea,_0x5415('0xd'),JSON['stringify'](_0x448b4f));if(_0x448b4f[_0x5415('0xe')]){if(_0x448b4f['error'][_0x5415('0xf')]===0x1f4){logger[_0x5415('0xe')]('MailApplication,\x20%s,\x20%s',_0x3c91ea,_0x448b4f['error'][_0x5415('0x10')]);return _0x5b0a3b(_0x448b4f[_0x5415('0xe')][_0x5415('0x10')]);}logger[_0x5415('0xe')](_0x5415('0xb'),_0x3c91ea,_0x448b4f[_0x5415('0xe')][_0x5415('0x10')]);return _0x20ed1b(_0x448b4f[_0x5415('0xe')][_0x5415('0x10')]);}else{logger['info'](_0x5415('0xb'),_0x3c91ea,_0x5415('0xd'));_0x20ed1b(_0x448b4f[_0x5415('0x11')][_0x5415('0x10')]);}})[_0x5415('0x12')](function(_0x49cd16){logger[_0x5415('0xe')](_0x5415('0xb'),_0x3c91ea,_0x49cd16);_0x5b0a3b(_0x49cd16);});});}exports[_0x5415('0x13')]=function(_0x556164){var _0x254dd4=this;return new Promise(function(_0xda73c6,_0x12812f){return db[_0x5415('0x14')][_0x5415('0x15')](_0x556164[_0x5415('0x16')],{'raw':_0x556164[_0x5415('0x17')]?_0x556164[_0x5415('0x17')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x556164[_0x5415('0x17')]?_0x556164[_0x5415('0x17')][_0x5415('0x18')]||null:null,'attributes':_0x556164[_0x5415('0x17')]?_0x556164[_0x5415('0x17')]['attributes']||null:null,'limit':_0x556164[_0x5415('0x17')]?_0x556164[_0x5415('0x17')][_0x5415('0x19')]||null:null})[_0x5415('0x9')](function(_0x2a2656){logger['info'](_0x5415('0x13'),_0x556164);logger[_0x5415('0x1a')]('UpdateMailApplication',_0x556164,JSON[_0x5415('0x1b')](_0x2a2656));_0xda73c6(_0x2a2656);})[_0x5415('0x12')](function(_0x2ef327){logger[_0x5415('0xe')](_0x5415('0x13'),_0x2ef327[_0x5415('0x10')],_0x556164);_0x12812f(_0x254dd4['error'](0x1f4,_0x2ef327[_0x5415('0x10')]));});});};