7a7fea41099ffff3163f395dafa5807f1e379cd5
[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 _0x9f02=['bluebird','./rpc/mailAccount','../../mysqldb','resolve','then','getMailAccounts','initMailAccounts','refresh','mailAccounts','listen','findOne','loginMailFrequency','catch'];(function(_0x3cb5bd,_0x11882c){var _0x5451fa=function(_0x4288cd){while(--_0x4288cd){_0x3cb5bd['push'](_0x3cb5bd['shift']());}};_0x5451fa(++_0x11882c);}(_0x9f02,0x68));var _0x29f0=function(_0x3fbccf,_0x14ff02){_0x3fbccf=_0x3fbccf-0x0;var _0x43657e=_0x9f02[_0x3fbccf];return _0x43657e;};'use strict';var BPromise=require(_0x29f0('0x0'));var server=require('./server');var Realtime=require('./realtime');var EmailChannel=require('./lib/email');var mailAccount=require(_0x29f0('0x1'));var realtime=new Realtime();var email=new EmailChannel(realtime);var db=require(_0x29f0('0x2'))['db'];function initRealtime(){return BPromise[_0x29f0('0x3')]()[_0x29f0('0x4')](mailAccount[_0x29f0('0x5')]())['then'](realtime[_0x29f0('0x6')]())['then'](function(){email[_0x29f0('0x7')](realtime[_0x29f0('0x8')]);return realtime;});}function main(){return server[_0x29f0('0x9')](realtime,email)['then'](function(_0x4d47b3){return initRealtime();})['then'](function(_0x1da49e){return db['Setting'][_0x29f0('0xa')]({'attributes':['id',_0x29f0('0xb')],'raw':!![]});})[_0x29f0('0x4')](function(_0x529ded){return setInterval(initRealtime,_0x529ded['loginMailFrequency']*0x3e8);})[_0x29f0('0xc')](function(_0x5a8eb2){console['log'](_0x5a8eb2);});}main();