784e5d391ce0368ed1eb7f17eb86660263c638ab
[motion2.git] / server / services / email / index.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 _0x599f=['mailAccounts','getSettings','loginMailFrequency','catch','Email\x20service\x20initialization','./server','./lib/email','./rpc/mailAccount','../../config/logger','email','resolve','then','getMailAccounts','initMailAccounts','refresh'];(function(_0x1d03a4,_0x170c84){var _0x59c81a=function(_0x4eb042){while(--_0x4eb042){_0x1d03a4['push'](_0x1d03a4['shift']());}};_0x59c81a(++_0x170c84);}(_0x599f,0x104));var _0xf599=function(_0x1a71c4,_0x440bcf){_0x1a71c4=_0x1a71c4-0x0;var _0x5a3605=_0x599f[_0x1a71c4];return _0x5a3605;};'use strict';var server=require(_0xf599('0x0'));var Realtime=require('./realtime');var EmailChannel=require(_0xf599('0x1'));var mailAccount=require(_0xf599('0x2'));var setting=require('./rpc/setting');var logger=require(_0xf599('0x3'))(_0xf599('0x4'));var realtime=new Realtime();var email=new EmailChannel(realtime);function initRealtime(){return Promise[_0xf599('0x5')]()[_0xf599('0x6')](mailAccount[_0xf599('0x7')]())['then'](realtime[_0xf599('0x8')]())[_0xf599('0x6')](function(){email[_0xf599('0x9')](realtime[_0xf599('0xa')]);return realtime;});}function main(){return server['listen'](realtime,email)['then'](function(){return initRealtime();})['then'](function(){return setting[_0xf599('0xb')]();})[_0xf599('0x6')](function(_0x8122){return setInterval(initRealtime,_0x8122[_0xf599('0xc')]*0x3e8);})[_0xf599('0xd')](function(_0x3140cd){logger['error'](_0xf599('0xe'),_0x3140cd);});}main();