From ecb4a05d9ad05bcc4c323f94e8b7aa829cf1cb23 Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Sat, 6 Jun 2026 18:39:31 +0200 Subject: [PATCH] Add avatarUrl to new search alerts email --- backend/api/package.json | 2 +- backend/api/src/app.ts | 2 +- backend/api/src/send-search-notifications.ts | 5 +-- backend/email/emails/functions/helpers.tsx | 2 +- ...earch_alerts.tsx => new-search-alerts.tsx} | 40 ++++++++++++++++--- common/src/profiles/bookmarked_searches.ts | 1 + .../{curl.sh => send_search_notifications.sh} | 0 7 files changed, 39 insertions(+), 13 deletions(-) rename backend/email/emails/{new-search_alerts.tsx => new-search-alerts.tsx} (83%) rename scripts/{curl.sh => send_search_notifications.sh} (100%) diff --git a/backend/api/package.json b/backend/api/package.json index 81e4af39..2eddba6c 100644 --- a/backend/api/package.json +++ b/backend/api/package.json @@ -1,6 +1,6 @@ { "name": "@compass/api", - "version": "1.43.0", + "version": "1.44.0", "private": true, "description": "Backend API endpoints", "main": "src/serve.ts", diff --git a/backend/api/src/app.ts b/backend/api/src/app.ts index 862dfc63..d50be944 100644 --- a/backend/api/src/app.ts +++ b/backend/api/src/app.ts @@ -692,7 +692,7 @@ Object.entries(handlers).forEach(([path, handler]) => { // Internal Endpoints app.post(pathWithPrefix('/internal/send-search-notifications'), async (req, res) => { const apiKey = req.header('x-api-key') - if (apiKey !== process.env.COMPASS_API_KEY) { + if (!IS_LOCAL && apiKey !== process.env.COMPASS_API_KEY) { return res.status(401).json({error: 'Unauthorized'}) } diff --git a/backend/api/src/send-search-notifications.ts b/backend/api/src/send-search-notifications.ts index b1d0c104..d4a3616d 100644 --- a/backend/api/src/send-search-notifications.ts +++ b/backend/api/src/send-search-notifications.ts @@ -70,10 +70,7 @@ export const sendSearchNotifications = async () => { matches[row.creator_id].matches.push({ id: row.creator_id, description: {filters: row.search_filters, location: row.location}, - matches: profiles.map((item: any) => ({ - name: item.name, - username: item.username, - })), + matches: profiles.map((profile: any) => profile.user), }) } debug('matches:', JSON.stringify(matches, null, 2)) diff --git a/backend/email/emails/functions/helpers.tsx b/backend/email/emails/functions/helpers.tsx index 5dbfcaeb..7c6b5089 100644 --- a/backend/email/emails/functions/helpers.tsx +++ b/backend/email/emails/functions/helpers.tsx @@ -7,7 +7,7 @@ import { getNotificationDestinationsForUser, UNSUBSCRIBE_URL, } from 'common/user-notification-preferences' -import NewSearchAlertsEmail from 'email/new-search_alerts' +import NewSearchAlertsEmail from 'email/new-search-alerts' import ShareCompassEmail from 'email/share-compass' import WelcomeEmail from 'email/welcome' import * as admin from 'firebase-admin' diff --git a/backend/email/emails/new-search_alerts.tsx b/backend/email/emails/new-search-alerts.tsx similarity index 83% rename from backend/email/emails/new-search_alerts.tsx rename to backend/email/emails/new-search-alerts.tsx index 16f828ae..562ed70e 100644 --- a/backend/email/emails/new-search_alerts.tsx +++ b/backend/email/emails/new-search-alerts.tsx @@ -1,4 +1,14 @@ -import {Body, Container, Head, Html, Link, Preview, Section, Text} from '@react-email/components' +import { + Body, + Container, + Head, + Html, + Img, + Link, + Preview, + Section, + Text, +} from '@react-email/components' import {DOMAIN} from 'common/envs/constants' import {FilterFields} from 'common/filters' import {formatFilters, locationType} from 'common/filters-format' @@ -88,21 +98,38 @@ export const NewSearchAlertsEmail = ({ style={{ display: 'inline-flex', alignItems: 'center', - flexWrap: 'wrap', - gap: '4px 8px', + gap: '12px', padding: '7px 14px', maxWidth: '100%', boxSizing: 'border-box', backgroundColor: '#faf3e9', border: '1px solid #e8c99e', borderRadius: '14px', - fontSize: '13px', lineHeight: '1.2', textDecoration: 'none', }} > - {p.name} - @{p.username} + {p.avatarUrl && ( + {`${p.username} + )} + + + {p.name} + + @{p.username} + ))} @@ -164,6 +191,7 @@ const matchSamples = [ { name: 'James Bond Junior', username: 'jamesbond', + avatarUrl: 'https://ui-avatars.com/api/?name=JB', }, { name: 'Lily', diff --git a/common/src/profiles/bookmarked_searches.ts b/common/src/profiles/bookmarked_searches.ts index 324a581f..d6816375 100644 --- a/common/src/profiles/bookmarked_searches.ts +++ b/common/src/profiles/bookmarked_searches.ts @@ -6,6 +6,7 @@ export interface MatchPrivateUser { export interface MatchUser { name: string username: string + avatarUrl?: string | null } export interface MatchesType { diff --git a/scripts/curl.sh b/scripts/send_search_notifications.sh similarity index 100% rename from scripts/curl.sh rename to scripts/send_search_notifications.sh