eaed08e69be022bc983ed22504e4faac309e5ae1
[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 _0xf360=['initMailAccounts','refresh','mailAccounts','listen','Setting','findOne','loginMailFrequency','log','bluebird','./server','./realtime','./rpc/mailAccount','resolve','then','getMailAccounts'];(function(_0x5ddafe,_0x1fb508){var _0x5e23aa=function(_0x423efc){while(--_0x423efc){_0x5ddafe['push'](_0x5ddafe['shift']());}};_0x5e23aa(++_0x1fb508);}(_0xf360,0x9e));var _0x0f36=function(_0x4565bf,_0x5ad9d6){_0x4565bf=_0x4565bf-0x0;var _0x5610ba=_0xf360[_0x4565bf];return _0x5610ba;};'use strict';var BPromise=require(_0x0f36('0x0'));var server=require(_0x0f36('0x1'));var Realtime=require(_0x0f36('0x2'));var EmailChannel=require('./lib/email');var mailAccount=require(_0x0f36('0x3'));var realtime=new Realtime();var email=new EmailChannel(realtime);var db=require('../../mysqldb')['db'];function initRealtime(){return BPromise[_0x0f36('0x4')]()[_0x0f36('0x5')](mailAccount[_0x0f36('0x6')]())['then'](realtime[_0x0f36('0x7')]())[_0x0f36('0x5')](function(){email[_0x0f36('0x8')](realtime[_0x0f36('0x9')]);return realtime;});}function main(){return server[_0x0f36('0xa')](realtime,email)[_0x0f36('0x5')](function(_0x2d4bb7){return initRealtime();})[_0x0f36('0x5')](function(_0x5c356f){return db[_0x0f36('0xb')][_0x0f36('0xc')]({'attributes':['id',_0x0f36('0xd')],'raw':!![]});})[_0x0f36('0x5')](function(_0x146814){return setInterval(initRealtime,_0x146814[_0x0f36('0xd')]*0x3e8);})['catch'](function(_0x35d5ee){console[_0x0f36('0xe')](_0x35d5ee);});}main();