From b4ece913835c3f8f428a563a63f0b60e3cc444ab Mon Sep 17 00:00:00 2001 From: Matthew Meszaros Date: Mon, 25 May 2026 15:25:06 +0000 Subject: [PATCH] perf: drop dead cipher.Encrypt calls from warmup task MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit the two cipher.Encrypt calls on subject and body in HandleEmailTask discarded their ciphertext and the plaintext was what got sent. warmup mail is not stored at rest, so the only effect was warming the user's DEK in cache via the preceding Cipher() call — also removed since nothing else in the warmup path needs it. --- internal/tasks/email_task.go | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/internal/tasks/email_task.go b/internal/tasks/email_task.go index d47e9a11..cadfafdf 100644 --- a/internal/tasks/email_task.go +++ b/internal/tasks/email_task.go @@ -159,31 +159,16 @@ func (s *tasksService) HandleEmailTask(task *proto.ProcessTask) *errx.Error { emailBody = GenerateConversationEmail(conversation, *account, false) } - // STEP 8: Encrypt content + // STEP 8: Parse sender user ID for the outbound message. + // Warmup mail is not stored at rest, so we no longer call the cipher + // service here — the previous Encrypt() pair discarded its ciphertext + // and only served to warm the user's DEK in cache. userUUID, err := uuid.Parse(account.UserID) if err != nil { sentry.CaptureException(err) return errx.InternalError() } - cipher, err := s.cipherService.Cipher(ctx, userUUID) - if err != nil { - sentry.CaptureException(err) - return errx.InternalError() - } - - _, err = cipher.Encrypt(ctx, subject) - if err != nil { - sentry.CaptureException(err) - return errx.InternalError() - } - - _, err = cipher.Encrypt(ctx, emailBody) - if err != nil { - sentry.CaptureException(err) - return errx.InternalError() - } - // STEP 9: Generate Message-ID messageID := generateMessageID(account.Email)