1f3d02d0f87f3492de9e27c87248e3e5e3b9565b
[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 _0x94e6=['debug','error','code','message','info','result','catch','UpdateMailApplication','update','options','where','limit','util','moment','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','MailApplication,\x20%s,\x20%s','request\x20sent'];(function(_0x4a9fb1,_0x273043){var _0x348672=function(_0x142b69){while(--_0x142b69){_0x4a9fb1['push'](_0x4a9fb1['shift']());}};_0x348672(++_0x273043);}(_0x94e6,0x93));var _0x694e=function(_0x391329,_0x38e3a0){_0x391329=_0x391329-0x0;var _0x515fb5=_0x94e6[_0x391329];return _0x515fb5;};'use strict';var _=require('lodash');var util=require(_0x694e('0x0'));var moment=require(_0x694e('0x1'));var BPromise=require('bluebird');var rs=require(_0x694e('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x694e('0x3'))['db'];var utils=require(_0x694e('0x4'));var logger=require(_0x694e('0x5'))(_0x694e('0x6'));var config=require(_0x694e('0x7'));var jayson=require(_0x694e('0x8'));var client=jayson[_0x694e('0x9')][_0x694e('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x59e793,_0x5d7fc3,_0x12501e){return new BPromise(function(_0x1a81c5,_0x52f076){return client[_0x694e('0xb')](_0x59e793,_0x12501e)[_0x694e('0xc')](function(_0x24f4ad){logger['info'](_0x694e('0xd'),_0x5d7fc3,_0x694e('0xe'));logger[_0x694e('0xf')]('MailApplication,\x20%s,\x20%s,\x20%s',_0x5d7fc3,_0x694e('0xe'),JSON['stringify'](_0x24f4ad));if(_0x24f4ad[_0x694e('0x10')]){if(_0x24f4ad[_0x694e('0x10')][_0x694e('0x11')]===0x1f4){logger[_0x694e('0x10')]('MailApplication,\x20%s,\x20%s',_0x5d7fc3,_0x24f4ad[_0x694e('0x10')][_0x694e('0x12')]);return _0x52f076(_0x24f4ad[_0x694e('0x10')]['message']);}logger['error']('MailApplication,\x20%s,\x20%s',_0x5d7fc3,_0x24f4ad[_0x694e('0x10')][_0x694e('0x12')]);return _0x1a81c5(_0x24f4ad[_0x694e('0x10')]['message']);}else{logger[_0x694e('0x13')](_0x694e('0xd'),_0x5d7fc3,'request\x20sent');_0x1a81c5(_0x24f4ad[_0x694e('0x14')]['message']);}})[_0x694e('0x15')](function(_0x2d12bc){logger[_0x694e('0x10')]('MailApplication,\x20%s,\x20%s',_0x5d7fc3,_0x2d12bc);_0x52f076(_0x2d12bc);});});}exports[_0x694e('0x16')]=function(_0x421584){var _0xa0d6f1=this;return new Promise(function(_0x5ab413,_0x4eee5a){return db['MailApplication'][_0x694e('0x17')](_0x421584['body'],{'raw':_0x421584[_0x694e('0x18')]?_0x421584['options']['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x421584[_0x694e('0x18')]?_0x421584['options'][_0x694e('0x19')]||null:null,'attributes':_0x421584[_0x694e('0x18')]?_0x421584[_0x694e('0x18')]['attributes']||null:null,'limit':_0x421584['options']?_0x421584[_0x694e('0x18')][_0x694e('0x1a')]||null:null})[_0x694e('0xc')](function(_0x253533){logger[_0x694e('0x13')](_0x694e('0x16'),_0x421584);logger['debug'](_0x694e('0x16'),_0x421584,JSON['stringify'](_0x253533));_0x5ab413(_0x253533);})[_0x694e('0x15')](function(_0x3f8156){logger[_0x694e('0x10')](_0x694e('0x16'),_0x3f8156[_0x694e('0x12')],_0x421584);_0x4eee5a(_0xa0d6f1[_0x694e('0x10')](0x1f4,_0x3f8156[_0x694e('0x12')]));});});};