f105f9d076ee7bacd1c37cdd58af20242efc4d5d
[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 _0x5697=['./rpc/mailAccount','initMailAccounts','listen','then','Setting','loginMailFrequency','catch','log','bluebird','./realtime','./lib/email'];(function(_0x4a94b1,_0x4f2518){var _0x20949f=function(_0x1c4aa6){while(--_0x1c4aa6){_0x4a94b1['push'](_0x4a94b1['shift']());}};_0x20949f(++_0x4f2518);}(_0x5697,0x1b5));var _0x7569=function(_0x559a80,_0x3d193d){_0x559a80=_0x559a80-0x0;var _0x42f555=_0x5697[_0x559a80];return _0x42f555;};'use strict';var BPromise=require(_0x7569('0x0'));var server=require('./server');var Realtime=require(_0x7569('0x1'));var EmailChannel=require(_0x7569('0x2'));var mailAccount=require(_0x7569('0x3'));var realtime=new Realtime();var email=new EmailChannel(realtime);var db=require('../../mysqldb')['db'];function initRealtime(){return BPromise['resolve']()['then'](mailAccount['getMailAccounts']())['then'](realtime[_0x7569('0x4')]())['then'](function(){email['refresh'](realtime['mailAccounts']);return realtime;});}function main(){return server[_0x7569('0x5')](realtime,email)[_0x7569('0x6')](function(_0x30b7e2){return initRealtime();})[_0x7569('0x6')](function(_0x3c0470){return db[_0x7569('0x7')]['findOne']({'attributes':['id',_0x7569('0x8')],'raw':!![]});})['then'](function(_0x9458b7){return setInterval(initRealtime,_0x9458b7[_0x7569('0x8')]*0x3e8);})[_0x7569('0x9')](function(_0xa4f75a){console[_0x7569('0xa')](_0xa4f75a);});}main();