21c75f1ad617299979f0d1fae8ce2fc2aa0b494b
[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 _0xea81=['loginMailFrequency','catch','log','bluebird','./server','./realtime','./lib/email','resolve','then','getMailAccounts','initMailAccounts','listen','Setting','findOne'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xea81,0x1ed));var _0x1ea8=function(_0x49bb91,_0x86ecf3){_0x49bb91=_0x49bb91-0x0;var _0x2b4339=_0xea81[_0x49bb91];return _0x2b4339;};'use strict';var BPromise=require(_0x1ea8('0x0'));var server=require(_0x1ea8('0x1'));var Realtime=require(_0x1ea8('0x2'));var EmailChannel=require(_0x1ea8('0x3'));var mailAccount=require('./rpc/mailAccount');var realtime=new Realtime();var email=new EmailChannel(realtime);var db=require('../../mysqldb')['db'];function initRealtime(){return BPromise[_0x1ea8('0x4')]()[_0x1ea8('0x5')](mailAccount[_0x1ea8('0x6')]())[_0x1ea8('0x5')](realtime[_0x1ea8('0x7')]())['then'](function(){email['refresh'](realtime['mailAccounts']);return realtime;});}function main(){return server[_0x1ea8('0x8')](realtime,email)[_0x1ea8('0x5')](function(_0x43404b){return initRealtime();})[_0x1ea8('0x5')](function(_0x4ec13b){return db[_0x1ea8('0x9')][_0x1ea8('0xa')]({'attributes':['id',_0x1ea8('0xb')],'raw':!![]});})[_0x1ea8('0x5')](function(_0x495092){return setInterval(initRealtime,_0x495092['loginMailFrequency']*0x3e8);})[_0x1ea8('0xc')](function(_0x5bd5dc){console[_0x1ea8('0xd')](_0x5bd5dc);});}main();