53478f40928de2e12ee98fdd0ee608e31855ad5a
[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 _0x838b=['limit','stringify','catch','lodash','util','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','http','request','then','info','request\x20sent','debug','error','MailApplication,\x20%s,\x20%s','message','result','UpdateMailApplication','MailApplication','body','options','raw','where'];(function(_0x2482c5,_0x2d88ce){var _0x12a506=function(_0x5119af){while(--_0x5119af){_0x2482c5['push'](_0x2482c5['shift']());}};_0x12a506(++_0x2d88ce);}(_0x838b,0x1c3));var _0xb838=function(_0x1a8fba,_0x1e728b){_0x1a8fba=_0x1a8fba-0x0;var _0x3470c0=_0x838b[_0x1a8fba];return _0x3470c0;};'use strict';var _=require(_0xb838('0x0'));var util=require(_0xb838('0x1'));var moment=require('moment');var BPromise=require(_0xb838('0x2'));var rs=require(_0xb838('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xb838('0x4'))['db'];var utils=require(_0xb838('0x5'));var logger=require(_0xb838('0x6'))(_0xb838('0x7'));var config=require('../../config/environment');var jayson=require(_0xb838('0x8'));var client=jayson['client'][_0xb838('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x4bf752,_0x11933f,_0xe0d86e){return new BPromise(function(_0x13720f,_0x26207c){return client[_0xb838('0xa')](_0x4bf752,_0xe0d86e)[_0xb838('0xb')](function(_0x2e3ad3){logger[_0xb838('0xc')]('MailApplication,\x20%s,\x20%s',_0x11933f,_0xb838('0xd'));logger[_0xb838('0xe')]('MailApplication,\x20%s,\x20%s,\x20%s',_0x11933f,_0xb838('0xd'),JSON['stringify'](_0x2e3ad3));if(_0x2e3ad3[_0xb838('0xf')]){if(_0x2e3ad3[_0xb838('0xf')]['code']===0x1f4){logger[_0xb838('0xf')](_0xb838('0x10'),_0x11933f,_0x2e3ad3[_0xb838('0xf')][_0xb838('0x11')]);return _0x26207c(_0x2e3ad3[_0xb838('0xf')][_0xb838('0x11')]);}logger[_0xb838('0xf')](_0xb838('0x10'),_0x11933f,_0x2e3ad3[_0xb838('0xf')][_0xb838('0x11')]);return _0x13720f(_0x2e3ad3[_0xb838('0xf')][_0xb838('0x11')]);}else{logger['info']('MailApplication,\x20%s,\x20%s',_0x11933f,_0xb838('0xd'));_0x13720f(_0x2e3ad3[_0xb838('0x12')][_0xb838('0x11')]);}})['catch'](function(_0x2b8216){logger[_0xb838('0xf')](_0xb838('0x10'),_0x11933f,_0x2b8216);_0x26207c(_0x2b8216);});});}exports[_0xb838('0x13')]=function(_0x4e7cfa){var _0x18cf7d=this;return new Promise(function(_0xb6af7f,_0x497436){return db[_0xb838('0x14')]['update'](_0x4e7cfa[_0xb838('0x15')],{'raw':_0x4e7cfa[_0xb838('0x16')]?_0x4e7cfa[_0xb838('0x16')][_0xb838('0x17')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x4e7cfa[_0xb838('0x16')]?_0x4e7cfa['options'][_0xb838('0x18')]||null:null,'attributes':_0x4e7cfa[_0xb838('0x16')]?_0x4e7cfa[_0xb838('0x16')]['attributes']||null:null,'limit':_0x4e7cfa['options']?_0x4e7cfa[_0xb838('0x16')][_0xb838('0x19')]||null:null})[_0xb838('0xb')](function(_0x556170){logger[_0xb838('0xc')]('UpdateMailApplication',_0x4e7cfa);logger[_0xb838('0xe')](_0xb838('0x13'),_0x4e7cfa,JSON[_0xb838('0x1a')](_0x556170));_0xb6af7f(_0x556170);})[_0xb838('0x1b')](function(_0x15711c){logger[_0xb838('0xf')](_0xb838('0x13'),_0x15711c[_0xb838('0x11')],_0x4e7cfa);_0x497436(_0x18cf7d[_0xb838('0xf')](0x1f4,_0x15711c[_0xb838('0x11')]));});});};