9593170bebf8d50d176abb3ca5aa0ddebe1b4ff2
[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 _0x365c=['body','options','raw','where','attributes','lodash','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','then','info','MailApplication,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','UpdateMailApplication','MailApplication'];(function(_0x6c00b2,_0x2769d4){var _0x255585=function(_0x4e6067){while(--_0x4e6067){_0x6c00b2['push'](_0x6c00b2['shift']());}};_0x255585(++_0x2769d4);}(_0x365c,0x1d5));var _0xc365=function(_0x396602,_0x460f7b){_0x396602=_0x396602-0x0;var _0xa31941=_0x365c[_0x396602];return _0xa31941;};'use strict';var _=require(_0xc365('0x0'));var util=require('util');var moment=require(_0xc365('0x1'));var BPromise=require(_0xc365('0x2'));var rs=require(_0xc365('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xc365('0x4'))['db'];var utils=require(_0xc365('0x5'));var logger=require(_0xc365('0x6'))(_0xc365('0x7'));var config=require(_0xc365('0x8'));var jayson=require(_0xc365('0x9'));var client=jayson[_0xc365('0xa')][_0xc365('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x91976b,_0x44427e,_0x684752){return new BPromise(function(_0x2b22cf,_0x303ebb){return client['request'](_0x91976b,_0x684752)[_0xc365('0xc')](function(_0x4ae332){logger[_0xc365('0xd')](_0xc365('0xe'),_0x44427e,_0xc365('0xf'));logger['debug']('MailApplication,\x20%s,\x20%s,\x20%s',_0x44427e,_0xc365('0xf'),JSON[_0xc365('0x10')](_0x4ae332));if(_0x4ae332[_0xc365('0x11')]){if(_0x4ae332[_0xc365('0x11')][_0xc365('0x12')]===0x1f4){logger[_0xc365('0x11')](_0xc365('0xe'),_0x44427e,_0x4ae332['error']['message']);return _0x303ebb(_0x4ae332[_0xc365('0x11')]['message']);}logger[_0xc365('0x11')](_0xc365('0xe'),_0x44427e,_0x4ae332['error']['message']);return _0x2b22cf(_0x4ae332[_0xc365('0x11')][_0xc365('0x13')]);}else{logger[_0xc365('0xd')]('MailApplication,\x20%s,\x20%s',_0x44427e,_0xc365('0xf'));_0x2b22cf(_0x4ae332[_0xc365('0x14')]['message']);}})[_0xc365('0x15')](function(_0x11412d){logger[_0xc365('0x11')](_0xc365('0xe'),_0x44427e,_0x11412d);_0x303ebb(_0x11412d);});});}exports[_0xc365('0x16')]=function(_0x43e6e7){var _0x4c8ad3=this;return new Promise(function(_0x3868ae,_0x43cfc2){return db[_0xc365('0x17')]['update'](_0x43e6e7[_0xc365('0x18')],{'raw':_0x43e6e7['options']?_0x43e6e7[_0xc365('0x19')][_0xc365('0x1a')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x43e6e7[_0xc365('0x19')]?_0x43e6e7[_0xc365('0x19')][_0xc365('0x1b')]||null:null,'attributes':_0x43e6e7['options']?_0x43e6e7[_0xc365('0x19')][_0xc365('0x1c')]||null:null,'limit':_0x43e6e7['options']?_0x43e6e7[_0xc365('0x19')]['limit']||null:null})[_0xc365('0xc')](function(_0x3216b7){logger[_0xc365('0xd')](_0xc365('0x16'),_0x43e6e7);logger['debug'](_0xc365('0x16'),_0x43e6e7,JSON[_0xc365('0x10')](_0x3216b7));_0x3868ae(_0x3216b7);})[_0xc365('0x15')](function(_0x835de3){logger[_0xc365('0x11')](_0xc365('0x16'),_0x835de3[_0xc365('0x13')],_0x43e6e7);_0x43cfc2(_0x4c8ad3['error'](0x1f4,_0x835de3['message']));});});};