e641493ac598a3a5e2011e5e3fb8f4992f06873c
[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 _0x9f52=['./server','./lib/email','./rpc/setting','resolve','then','getMailAccounts','mailAccounts','getSettings','loginMailFrequency','catch','error'];(function(_0x4e15f4,_0x5a72f2){var _0x5a9643=function(_0x26c1d6){while(--_0x26c1d6){_0x4e15f4['push'](_0x4e15f4['shift']());}};_0x5a9643(++_0x5a72f2);}(_0x9f52,0x1ce));var _0x29f5=function(_0x56fb8d,_0x3f176a){_0x56fb8d=_0x56fb8d-0x0;var _0x40d9fe=_0x9f52[_0x56fb8d];return _0x40d9fe;};'use strict';var server=require(_0x29f5('0x0'));var Realtime=require('./realtime');var EmailChannel=require(_0x29f5('0x1'));var mailAccount=require('./rpc/mailAccount');var setting=require(_0x29f5('0x2'));var logger=require('../../config/logger')('email');var realtime=new Realtime();var email=new EmailChannel(realtime);function initRealtime(){return Promise[_0x29f5('0x3')]()[_0x29f5('0x4')](mailAccount[_0x29f5('0x5')]())[_0x29f5('0x4')](realtime['initMailAccounts']())['then'](function(){email['refresh'](realtime[_0x29f5('0x6')]);return realtime;});}function main(){return server['listen'](realtime,email)[_0x29f5('0x4')](function(){return initRealtime();})[_0x29f5('0x4')](function(){return setting[_0x29f5('0x7')]();})['then'](function(_0x58cb34){return setInterval(initRealtime,_0x58cb34[_0x29f5('0x8')]*0x3e8);})[_0x29f5('0x9')](function(_0x21da0a){logger[_0x29f5('0xa')]('Email\x20service\x20initialization',_0x21da0a);});}main();