12cb0f885fdbcc23e7fd718961c61e549439b8cb
[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 _0x6546=['../../config/utils','../../config/logger','../../config/environment','client','http','request','then','info','request\x20sent','stringify','error','code','MailApplication,\x20%s,\x20%s','message','result','catch','UpdateMailApplication','MailApplication','update','body','options','raw','where','attributes','limit','debug','lodash','util','moment','randomstring','ioredis','../../mysqldb'];(function(_0xce8183,_0x567545){var _0x27c555=function(_0x2b1dd5){while(--_0x2b1dd5){_0xce8183['push'](_0xce8183['shift']());}};_0x27c555(++_0x567545);}(_0x6546,0x19a));var _0x6654=function(_0xc5fd81,_0x286a81){_0xc5fd81=_0xc5fd81-0x0;var _0x55d2e4=_0x6546[_0xc5fd81];return _0x55d2e4;};'use strict';var _=require(_0x6654('0x0'));var util=require(_0x6654('0x1'));var moment=require(_0x6654('0x2'));var BPromise=require('bluebird');var rs=require(_0x6654('0x3'));var fs=require('fs');var Redis=require(_0x6654('0x4'));var db=require(_0x6654('0x5'))['db'];var utils=require(_0x6654('0x6'));var logger=require(_0x6654('0x7'))('rpc');var config=require(_0x6654('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x6654('0x9')][_0x6654('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x1abdd6,_0x2e65f3,_0x4ee828){return new BPromise(function(_0xf7d8cf,_0x2af691){return client[_0x6654('0xb')](_0x1abdd6,_0x4ee828)[_0x6654('0xc')](function(_0x415443){logger[_0x6654('0xd')]('MailApplication,\x20%s,\x20%s',_0x2e65f3,'request\x20sent');logger['debug']('MailApplication,\x20%s,\x20%s,\x20%s',_0x2e65f3,_0x6654('0xe'),JSON[_0x6654('0xf')](_0x415443));if(_0x415443[_0x6654('0x10')]){if(_0x415443[_0x6654('0x10')][_0x6654('0x11')]===0x1f4){logger[_0x6654('0x10')](_0x6654('0x12'),_0x2e65f3,_0x415443['error'][_0x6654('0x13')]);return _0x2af691(_0x415443[_0x6654('0x10')][_0x6654('0x13')]);}logger[_0x6654('0x10')](_0x6654('0x12'),_0x2e65f3,_0x415443[_0x6654('0x10')]['message']);return _0xf7d8cf(_0x415443[_0x6654('0x10')][_0x6654('0x13')]);}else{logger[_0x6654('0xd')](_0x6654('0x12'),_0x2e65f3,'request\x20sent');_0xf7d8cf(_0x415443[_0x6654('0x14')][_0x6654('0x13')]);}})[_0x6654('0x15')](function(_0x3620f7){logger[_0x6654('0x10')](_0x6654('0x12'),_0x2e65f3,_0x3620f7);_0x2af691(_0x3620f7);});});}exports[_0x6654('0x16')]=function(_0x8a5e43){var _0x39dd46=this;return new Promise(function(_0xbb8e66,_0x468149){return db[_0x6654('0x17')][_0x6654('0x18')](_0x8a5e43[_0x6654('0x19')],{'raw':_0x8a5e43[_0x6654('0x1a')]?_0x8a5e43[_0x6654('0x1a')][_0x6654('0x1b')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x8a5e43['options']?_0x8a5e43[_0x6654('0x1a')][_0x6654('0x1c')]||null:null,'attributes':_0x8a5e43[_0x6654('0x1a')]?_0x8a5e43[_0x6654('0x1a')][_0x6654('0x1d')]||null:null,'limit':_0x8a5e43[_0x6654('0x1a')]?_0x8a5e43['options'][_0x6654('0x1e')]||null:null})[_0x6654('0xc')](function(_0x5637f7){logger[_0x6654('0xd')]('UpdateMailApplication',_0x8a5e43);logger[_0x6654('0x1f')]('UpdateMailApplication',_0x8a5e43,JSON['stringify'](_0x5637f7));_0xbb8e66(_0x5637f7);})[_0x6654('0x15')](function(_0x3e7e0d){logger['error'](_0x6654('0x16'),_0x3e7e0d['message'],_0x8a5e43);_0x468149(_0x39dd46['error'](0x1f4,_0x3e7e0d[_0x6654('0x13')]));});});};