/// <inheritdoc cref="IMailboxService.GetMailboxBySenderEmailAddress(string, bool)"/> public Mailbox GetMailboxBySenderEmailAddress(string senderEmailAddress, bool userMailboxesOnly = true) { var allMailboxes = _mailboxRepository.GetAll(userMailboxesOnly); return(userMailboxesOnly ? allMailboxes.FirstOrDefault(m => m.SenderEmailAddress == senderEmailAddress && (m.OwnerId.Equals(_userConnection.CurrentUser.Id) || m.IsShared)) : allMailboxes.FirstOrDefault(m => m.SenderEmailAddress == senderEmailAddress)); }
public void ClearOldEmails() { this.logger.LogInformation("Starting MailRetention job"); var mailboxes = mailboxRepository.GetAll(); foreach (var mailbox in mailboxes) { try { mailboxRepository.ClearOldEmails(mailbox.MailboxId); } catch (Exception e) { this.logger.LogError(e, $"Clearing emails failed for mailbox {mailbox.Name} older then {mailbox.MailRetention} days."); } } this.logger.LogInformation("Finished MailRetention job"); }