Ejemplo n.º 1
0
        /// <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));
        }
Ejemplo n.º 2
0
        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");
        }