Built motion from commit (unavailable).|2.5.6
[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 _0xea44=['loginMailFrequency','bluebird','./server','./realtime','./lib/email','../../mysqldb','resolve','getMailAccounts','then','initMailAccounts','mailAccounts','listen','Setting','findOne'];(function(_0x8a8ac9,_0x11b447){var _0x4df81d=function(_0x41320c){while(--_0x41320c){_0x8a8ac9['push'](_0x8a8ac9['shift']());}};_0x4df81d(++_0x11b447);}(_0xea44,0x1a5));var _0x4ea4=function(_0x1ed259,_0x419b04){_0x1ed259=_0x1ed259-0x0;var _0x3d47d2=_0xea44[_0x1ed259];return _0x3d47d2;};'use strict';var BPromise=require(_0x4ea4('0x0'));var server=require(_0x4ea4('0x1'));var Realtime=require(_0x4ea4('0x2'));var EmailChannel=require(_0x4ea4('0x3'));var mailAccount=require('./rpc/mailAccount');var realtime=new Realtime();var email=new EmailChannel(realtime);var db=require(_0x4ea4('0x4'))['db'];function initRealtime(){return BPromise[_0x4ea4('0x5')]()['then'](mailAccount[_0x4ea4('0x6')]())[_0x4ea4('0x7')](realtime[_0x4ea4('0x8')]())[_0x4ea4('0x7')](function(){email['refresh'](realtime[_0x4ea4('0x9')]);return realtime;});}function main(){return server[_0x4ea4('0xa')](realtime,email)[_0x4ea4('0x7')](function(_0x3ba1b6){return initRealtime();})[_0x4ea4('0x7')](function(_0xb91515){return db[_0x4ea4('0xb')][_0x4ea4('0xc')]({'attributes':['id',_0x4ea4('0xd')],'raw':!![]});})['then'](function(_0x333358){return setInterval(initRealtime,_0x333358['loginMailFrequency']*0x3e8);})['catch'](function(_0x42732c){console['log'](_0x42732c);});}main();