Services+Worker
This commit is contained in:
@@ -1,18 +1,22 @@
|
||||
using MailKit.Search;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.AIHIT.Settings;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.Mail.Services;
|
||||
|
||||
namespace PARR.AIHIT
|
||||
{
|
||||
internal class Syncher
|
||||
internal class Syncher : ISyncher
|
||||
{
|
||||
private readonly ILogger<Syncher> logger;
|
||||
private readonly IMailService mailService;
|
||||
private readonly SyncherSettings syncherSettings;
|
||||
private readonly IHostService hostService;
|
||||
|
||||
public Syncher(ILogger<Syncher> logger, IMailService mailService, SyncherSettings syncherSettings)
|
||||
public Syncher(ILogger<Syncher> logger, IMailService mailService, SyncherSettings syncherSettings, IHostService hostService)
|
||||
{
|
||||
this.hostService = hostService;
|
||||
this.logger = logger;
|
||||
this.mailService = mailService;
|
||||
this.syncherSettings = syncherSettings;
|
||||
@@ -20,6 +24,7 @@ namespace PARR.AIHIT
|
||||
|
||||
public async Task InvokeAsync()
|
||||
{
|
||||
var hosts = await hostService.Get().ToListAsync();
|
||||
var messages = await mailService.CheckMailAsync(SearchQuery.NotSeen);
|
||||
if (!messages.Any())
|
||||
{
|
||||
@@ -29,9 +34,9 @@ namespace PARR.AIHIT
|
||||
// var filtered = messages.Where(m => includeAddresses.Any(i => m.Envelope.From.Mailboxes.First().Address == i)).ToList();
|
||||
|
||||
var filtered = messages.Where(m => syncherSettings.IncludeAddressesArray.Any(i => m.Envelope.From.Mailboxes.First().Address == i)).ToList();
|
||||
foreach ( var message in filtered)
|
||||
foreach (var message in filtered)
|
||||
{
|
||||
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user