Skip to content

fix(email-service): Notify search on label updates#635

Merged
evanhutnik merged 3 commits intomainfrom
evan/comms-79-send-search-message-on-email-label-updatemessage-updated
Dec 15, 2025
Merged

fix(email-service): Notify search on label updates#635
evanhutnik merged 3 commits intomainfrom
evan/comms-79-send-search-message-on-email-label-updatemessage-updated

Conversation

@evanhutnik
Copy link
Copy Markdown
Contributor

Summary

Originally we were only planning on using email search for content matches, so we only notified search when new messages were added to the database. Now we also include label information in opensearch. So we need to notify search whenever there is a label change to a message.

Sometimes gmail notifies us of label changes through an UpsertMessage notification, and sometimes through an UpdateLabel notification. We now notify search if either event happens for a message.

Also did some refactoring of upsert message code. Back in the day we were handling multiple email message updates in a single pubsub message. Now we only handle one email message update per message, so the logic can be simplified.

Screenshots, GIFs, and Videos

@evanhutnik evanhutnik requested a review from a team as a code owner December 15, 2025 19:45
@linear
Copy link
Copy Markdown

linear bot commented Dec 15, 2025

.fetch_optional(pool)
.await
.context("Failed to query messages for db_id")?;
.context("Failed to query message/thread id by provider id")?;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

context

Ok(db_ids)
match row {
Some((message_id, thread_id)) => Ok((message_id, thread_id)),
None => Err(anyhow!(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anyhow::bail

.into_iter()
.filter(|id| !existing_set.contains(id))
.collect();
.with_context(|| format!("Failed to check existing message for link_id {}", link_id))?;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

context

@evanhutnik evanhutnik merged commit f8c5ffb into main Dec 15, 2025
35 checks passed
@evanhutnik evanhutnik deleted the evan/comms-79-send-search-message-on-email-label-updatemessage-updated branch December 15, 2025 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants