04175756b73879eade3f5b444e7d12106bbf2c26
[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 _0xfc65=['catch','bluebird','./lib/email','./rpc/mailAccount','../../mysqldb','resolve','then','getMailAccounts','initMailAccounts','refresh','mailAccounts','listen','Setting','findOne','loginMailFrequency'];(function(_0x23e2a3,_0x13e18e){var _0x27901b=function(_0x40fcc7){while(--_0x40fcc7){_0x23e2a3['push'](_0x23e2a3['shift']());}};_0x27901b(++_0x13e18e);}(_0xfc65,0x1e1));var _0x5fc6=function(_0x59808c,_0x4e2244){_0x59808c=_0x59808c-0x0;var _0x2e2546=_0xfc65[_0x59808c];return _0x2e2546;};'use strict';var BPromise=require(_0x5fc6('0x0'));var server=require('./server');var Realtime=require('./realtime');var EmailChannel=require(_0x5fc6('0x1'));var mailAccount=require(_0x5fc6('0x2'));var realtime=new Realtime();var email=new EmailChannel(realtime);var db=require(_0x5fc6('0x3'))['db'];function initRealtime(){return BPromise[_0x5fc6('0x4')]()[_0x5fc6('0x5')](mailAccount[_0x5fc6('0x6')]())[_0x5fc6('0x5')](realtime[_0x5fc6('0x7')]())[_0x5fc6('0x5')](function(){email[_0x5fc6('0x8')](realtime[_0x5fc6('0x9')]);return realtime;});}function main(){return server[_0x5fc6('0xa')](realtime,email)[_0x5fc6('0x5')](function(_0x572941){return initRealtime();})[_0x5fc6('0x5')](function(_0x1f1409){return db[_0x5fc6('0xb')][_0x5fc6('0xc')]({'attributes':['id',_0x5fc6('0xd')],'raw':!![]});})[_0x5fc6('0x5')](function(_0x23c4e2){return setInterval(initRealtime,_0x23c4e2[_0x5fc6('0xd')]*0x3e8);})[_0x5fc6('0xe')](function(_0x29781f){console['log'](_0x29781f);});}main();