Built motion from commit (unavailable).|2.5.11
[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 _0xd8fb=['mailAccounts','loginMailFrequency','catch','bluebird','./server','./realtime','./lib/email','then','getMailAccounts','initMailAccounts'];(function(_0x3b380d,_0x4bf247){var _0x54502b=function(_0x35d207){while(--_0x35d207){_0x3b380d['push'](_0x3b380d['shift']());}};_0x54502b(++_0x4bf247);}(_0xd8fb,0x99));var _0xbd8f=function(_0x22109d,_0x1aaf9d){_0x22109d=_0x22109d-0x0;var _0x118ed3=_0xd8fb[_0x22109d];return _0x118ed3;};'use strict';var BPromise=require(_0xbd8f('0x0'));var server=require(_0xbd8f('0x1'));var Realtime=require(_0xbd8f('0x2'));var EmailChannel=require(_0xbd8f('0x3'));var mailAccount=require('./rpc/mailAccount');var realtime=new Realtime();var email=new EmailChannel(realtime);var db=require('../../mysqldb')['db'];function initRealtime(){return BPromise['resolve']()[_0xbd8f('0x4')](mailAccount[_0xbd8f('0x5')]())['then'](realtime[_0xbd8f('0x6')]())[_0xbd8f('0x4')](function(){email['refresh'](realtime[_0xbd8f('0x7')]);return realtime;});}function main(){return server['listen'](realtime,email)[_0xbd8f('0x4')](function(_0x578499){return initRealtime();})[_0xbd8f('0x4')](function(_0x403edc){return db['Setting']['findOne']({'attributes':['id',_0xbd8f('0x8')],'raw':!![]});})[_0xbd8f('0x4')](function(_0x2a55b5){return setInterval(initRealtime,_0x2a55b5['loginMailFrequency']*0x3e8);})[_0xbd8f('0x9')](function(_0x42ae20){console['log'](_0x42ae20);});}main();