Built motion from commit (unavailable).|2.4.21
[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 _0x4ce6=['Setting','findOne','loginMailFrequency','log','bluebird','./realtime','./lib/email','./rpc/mailAccount','../../mysqldb','resolve','then','refresh','mailAccounts'];(function(_0x42c8d5,_0x13eb23){var _0x379bbc=function(_0x48e110){while(--_0x48e110){_0x42c8d5['push'](_0x42c8d5['shift']());}};_0x379bbc(++_0x13eb23);}(_0x4ce6,0x108));var _0x64ce=function(_0x5c8827,_0x5bc5d7){_0x5c8827=_0x5c8827-0x0;var _0x50ffd5=_0x4ce6[_0x5c8827];return _0x50ffd5;};'use strict';var BPromise=require(_0x64ce('0x0'));var server=require('./server');var Realtime=require(_0x64ce('0x1'));var EmailChannel=require(_0x64ce('0x2'));var mailAccount=require(_0x64ce('0x3'));var realtime=new Realtime();var email=new EmailChannel(realtime);var db=require(_0x64ce('0x4'))['db'];function initRealtime(){return BPromise[_0x64ce('0x5')]()[_0x64ce('0x6')](mailAccount['getMailAccounts']())[_0x64ce('0x6')](realtime['initMailAccounts']())['then'](function(){email[_0x64ce('0x7')](realtime[_0x64ce('0x8')]);return realtime;});}function main(){return server['listen'](realtime,email)[_0x64ce('0x6')](function(_0x3c279f){return initRealtime();})[_0x64ce('0x6')](function(_0x1b253e){return db[_0x64ce('0x9')][_0x64ce('0xa')]({'attributes':['id',_0x64ce('0xb')],'raw':!![]});})[_0x64ce('0x6')](function(_0x42eada){return setInterval(initRealtime,_0x42eada[_0x64ce('0xb')]*0x3e8);})['catch'](function(_0x3d7259){console[_0x64ce('0xc')](_0x3d7259);});}main();