3db8b7c3631fd1974b0799f64e41214e9b8594ab
[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 _0x65fb=['then','info','MailApplication,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','UpdateMailApplication','body','options','where','limit','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request'];(function(_0x2cb642,_0x248ad5){var _0x346dad=function(_0x1905fb){while(--_0x1905fb){_0x2cb642['push'](_0x2cb642['shift']());}};_0x346dad(++_0x248ad5);}(_0x65fb,0x1e0));var _0xb65f=function(_0x25b24a,_0x1c0163){_0x25b24a=_0x25b24a-0x0;var _0x224e68=_0x65fb[_0x25b24a];return _0x224e68;};'use strict';var _=require(_0xb65f('0x0'));var util=require(_0xb65f('0x1'));var moment=require(_0xb65f('0x2'));var BPromise=require(_0xb65f('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xb65f('0x4'));var db=require(_0xb65f('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0xb65f('0x6'))(_0xb65f('0x7'));var config=require(_0xb65f('0x8'));var jayson=require(_0xb65f('0x9'));var client=jayson[_0xb65f('0xa')][_0xb65f('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x3f9325,_0x433816,_0x5e10a6){return new BPromise(function(_0x26bd57,_0x4e46bf){return client[_0xb65f('0xc')](_0x3f9325,_0x5e10a6)[_0xb65f('0xd')](function(_0x176cf7){logger[_0xb65f('0xe')](_0xb65f('0xf'),_0x433816,_0xb65f('0x10'));logger[_0xb65f('0x11')]('MailApplication,\x20%s,\x20%s,\x20%s',_0x433816,'request\x20sent',JSON[_0xb65f('0x12')](_0x176cf7));if(_0x176cf7['error']){if(_0x176cf7[_0xb65f('0x13')][_0xb65f('0x14')]===0x1f4){logger[_0xb65f('0x13')](_0xb65f('0xf'),_0x433816,_0x176cf7[_0xb65f('0x13')][_0xb65f('0x15')]);return _0x4e46bf(_0x176cf7[_0xb65f('0x13')]['message']);}logger[_0xb65f('0x13')](_0xb65f('0xf'),_0x433816,_0x176cf7[_0xb65f('0x13')][_0xb65f('0x15')]);return _0x26bd57(_0x176cf7['error'][_0xb65f('0x15')]);}else{logger[_0xb65f('0xe')](_0xb65f('0xf'),_0x433816,_0xb65f('0x10'));_0x26bd57(_0x176cf7[_0xb65f('0x16')][_0xb65f('0x15')]);}})[_0xb65f('0x17')](function(_0x33ff68){logger[_0xb65f('0x13')](_0xb65f('0xf'),_0x433816,_0x33ff68);_0x4e46bf(_0x33ff68);});});}exports[_0xb65f('0x18')]=function(_0x588d96){var _0xfc8b5c=this;return new Promise(function(_0x34a258,_0x7e549e){return db['MailApplication']['update'](_0x588d96[_0xb65f('0x19')],{'raw':_0x588d96[_0xb65f('0x1a')]?_0x588d96[_0xb65f('0x1a')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x588d96[_0xb65f('0x1a')]?_0x588d96['options'][_0xb65f('0x1b')]||null:null,'attributes':_0x588d96[_0xb65f('0x1a')]?_0x588d96[_0xb65f('0x1a')]['attributes']||null:null,'limit':_0x588d96['options']?_0x588d96[_0xb65f('0x1a')][_0xb65f('0x1c')]||null:null})['then'](function(_0x370131){logger[_0xb65f('0xe')](_0xb65f('0x18'),_0x588d96);logger['debug'](_0xb65f('0x18'),_0x588d96,JSON[_0xb65f('0x12')](_0x370131));_0x34a258(_0x370131);})[_0xb65f('0x17')](function(_0x11bdfe){logger[_0xb65f('0x13')](_0xb65f('0x18'),_0x11bdfe[_0xb65f('0x15')],_0x588d96);_0x7e549e(_0xfc8b5c[_0xb65f('0x13')](0x1f4,_0x11bdfe['message']));});});};