d517ef898b48aea8a69ca2b4a0b36722f47ae9a2
[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 _0xe107=['update','body','options','where','attributes','limit','moment','bluebird','../../mysqldb','../../config/logger','rpc','../../config/environment','request','then','MailApplication,\x20%s,\x20%s','debug','stringify','error','code','message','info','request\x20sent','catch','UpdateMailApplication','MailApplication'];(function(_0x6e1239,_0x3562ac){var _0x418150=function(_0x279f06){while(--_0x279f06){_0x6e1239['push'](_0x6e1239['shift']());}};_0x418150(++_0x3562ac);}(_0xe107,0x14b));var _0x7e10=function(_0x2c0dd9,_0x140359){_0x2c0dd9=_0x2c0dd9-0x0;var _0x28608d=_0xe107[_0x2c0dd9];return _0x28608d;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x7e10('0x0'));var BPromise=require(_0x7e10('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x7e10('0x2'))['db'];var utils=require('../../config/utils');var logger=require(_0x7e10('0x3'))(_0x7e10('0x4'));var config=require(_0x7e10('0x5'));var jayson=require('jayson/promise');var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x438084,_0x56f2ca,_0x18c984){return new BPromise(function(_0x1c413a,_0x5de6d8){return client[_0x7e10('0x6')](_0x438084,_0x18c984)[_0x7e10('0x7')](function(_0x1529c9){logger['info'](_0x7e10('0x8'),_0x56f2ca,'request\x20sent');logger[_0x7e10('0x9')]('MailApplication,\x20%s,\x20%s,\x20%s',_0x56f2ca,'request\x20sent',JSON[_0x7e10('0xa')](_0x1529c9));if(_0x1529c9[_0x7e10('0xb')]){if(_0x1529c9[_0x7e10('0xb')][_0x7e10('0xc')]===0x1f4){logger[_0x7e10('0xb')](_0x7e10('0x8'),_0x56f2ca,_0x1529c9[_0x7e10('0xb')][_0x7e10('0xd')]);return _0x5de6d8(_0x1529c9['error'][_0x7e10('0xd')]);}logger[_0x7e10('0xb')](_0x7e10('0x8'),_0x56f2ca,_0x1529c9['error'][_0x7e10('0xd')]);return _0x1c413a(_0x1529c9[_0x7e10('0xb')][_0x7e10('0xd')]);}else{logger[_0x7e10('0xe')](_0x7e10('0x8'),_0x56f2ca,_0x7e10('0xf'));_0x1c413a(_0x1529c9['result'][_0x7e10('0xd')]);}})[_0x7e10('0x10')](function(_0x150c4e){logger[_0x7e10('0xb')]('MailApplication,\x20%s,\x20%s',_0x56f2ca,_0x150c4e);_0x5de6d8(_0x150c4e);});});}exports[_0x7e10('0x11')]=function(_0x1e6fc9){var _0x45ed2e=this;return new Promise(function(_0x175409,_0x2fc853){return db[_0x7e10('0x12')][_0x7e10('0x13')](_0x1e6fc9[_0x7e10('0x14')],{'raw':_0x1e6fc9[_0x7e10('0x15')]?_0x1e6fc9[_0x7e10('0x15')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x1e6fc9[_0x7e10('0x15')]?_0x1e6fc9[_0x7e10('0x15')][_0x7e10('0x16')]||null:null,'attributes':_0x1e6fc9[_0x7e10('0x15')]?_0x1e6fc9[_0x7e10('0x15')][_0x7e10('0x17')]||null:null,'limit':_0x1e6fc9[_0x7e10('0x15')]?_0x1e6fc9[_0x7e10('0x15')][_0x7e10('0x18')]||null:null})[_0x7e10('0x7')](function(_0x187b4a){logger[_0x7e10('0xe')](_0x7e10('0x11'),_0x1e6fc9);logger[_0x7e10('0x9')](_0x7e10('0x11'),_0x1e6fc9,JSON[_0x7e10('0xa')](_0x187b4a));_0x175409(_0x187b4a);})[_0x7e10('0x10')](function(_0x4960a1){logger[_0x7e10('0xb')](_0x7e10('0x11'),_0x4960a1['message'],_0x1e6fc9);_0x2fc853(_0x45ed2e['error'](0x1f4,_0x4960a1[_0x7e10('0xd')]));});});};