The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
fix(mail-ingest): send mailInbox:settings, and give both events their client place
Maurice1d052f725f5b
diff --git a/client/src/api/wsEventPolicy.ts b/client/src/api/wsEventPolicy.tsindex 7ab318b37..4a179e1ba 100644--- a/client/src/api/wsEventPolicy.ts+++ b/client/src/api/wsEventPolicy.ts@@ -161,6 +161,9 @@ export const HANDLED_OUTSIDE_TRIP_STORE = [export const IGNORED_WS_EVENTS: Partial<Record<TrekWsEventName, string>> = {'todo:assignees':'No screen shows who looks after a todo category (todoApi.getCategoryAssignees has no caller), so there is nothing to refresh.',+ // The mail import's inbox and settings card come with its client screens, which move these to their listener.+ 'mailInbox:changed': 'No screen shows the mail inbox or its open count yet, so there is nothing to refresh.',+ 'mailInbox:settings': 'No screen shows the mail import settings card yet, so there is nothing to read again.',}/**diff --git a/server/src/nest/mail-ingest/mail-ingest-inbox.service.ts b/server/src/nest/mail-ingest/mail-ingest-inbox.service.tsindex ebadc8eb1..0baec5405 100644--- a/server/src/nest/mail-ingest/mail-ingest-inbox.service.ts+++ b/server/src/nest/mail-ingest/mail-ingest-inbox.service.ts@@ -12,6 +12,7 @@ import { DomainError } from '../common/domain-error';import { MailReadService } from '../llm-parse/mail-read.service';import { MailIngestAddressService } from './mail-ingest-address.service';import { MailIngestIntakeService, type MailIntakeRefusal } from './mail-ingest-intake.service';+import { MailIngestNotifyService } from './mail-ingest-notify.service';import { MailIngestProcessJob } from './mail-ingest-process.job';import { MailIngestSettingsService } from './mail-ingest-settings.service';import { candidateView, messageView } from './mail-ingest-views';@@ -57,6 +58,7 @@ export class MailIngestInboxService {private readonly intake: MailIngestIntakeService,private readonly reader: MailReadService,private readonly job: MailIngestProcessJob,+ private readonly notify: MailIngestNotifyService,) {}/** The settings card. Where the import is off or not part of the plan it says so, and nothing else. */@@ -77,13 +79,16 @@ export class MailIngestInboxService {async updatePrefs(userId: number, update: MailIngestPrefsUpdateRequest): Promise<MailIngestSettingsResponse> {await this.requireAvailable();await this.settings.updatePrefs(userId, update);+ this.notify.settingsChanged(userId);return this.settingsOf(userId);}/** A new own address; the old one stops taking mail at once. */async renewOwnAddress(userId: number): Promise<MailIngestAddressResponse> {await this.requireAvailable();- return { address: await this.addresses.renewOwn(userId) };+ const address = await this.addresses.renewOwn(userId);+ this.notify.settingsChanged(userId);+ return { address };}async tripAddress(userId: number, tripId: number): Promise<MailIngestAddressResponse> {@@ -94,12 +99,15 @@ export class MailIngestInboxService {/** The person's address for the trip, made now or renewed. */async renewTripAddress(userId: number, tripId: number): Promise<MailIngestAddressResponse> {await this.requireAvailable();- return { address: await this.addresses.renewTripAddress(userId, tripId) };+ const address = await this.addresses.renewTripAddress(userId, tripId);+ this.notify.settingsChanged(userId);+ return { address };}async revokeTripAddress(userId: number, tripId: number): Promise<void> {await this.requireAvailable();await this.addresses.revokeTripAddress(userId, tripId);+ this.notify.settingsChanged(userId);}/** One page of the inbox, newest first, each entry with the mail it came from. */diff --git a/server/src/nest/mail-ingest/mail-ingest-notify.service.ts b/server/src/nest/mail-ingest/mail-ingest-notify.service.tsindex 50986e543..771b0f9d6 100644--- a/server/src/nest/mail-ingest/mail-ingest-notify.service.ts+++ b/server/src/nest/mail-ingest/mail-ingest-notify.service.ts@@ -33,6 +33,11 @@ export class MailIngestNotifyService {this.realtime.broadcastToUser(userId, { type: 'mailInbox:changed', pending });}+ /** Tells the person's open clients that their address or switches changed, so the settings card reads them again. */+ settingsChanged(userId: number): void {+ this.realtime.broadcastToUser(userId, { type: 'mailInbox:settings' });+ }+/** @txStandalone a notice reports a write that committed; a failed one undoes nothing. */async bookingAdded(forwarder: MailIngestPersonRow, booking: AddedBooking): Promise<void> {const params = {diff --git a/server/tests/unit/nest/mail-ingest/mail-ingest-notify.test.ts b/server/tests/unit/nest/mail-ingest/mail-ingest-notify.test.tsindex 754555887..cc2231ea8 100644--- a/server/tests/unit/nest/mail-ingest/mail-ingest-notify.test.ts+++ b/server/tests/unit/nest/mail-ingest/mail-ingest-notify.test.ts@@ -64,13 +64,15 @@ describe('MailIngestNotifyService', () => {expect(trip).toMatchObject({ scope: 'trip', targetId: 7, actorId: 3, params: { role: 'traveller', actor: 'mia' } });});- it('sends one note for waiting bookings, and survives a failed send', async () => {+ it('sends one note for waiting bookings, survives a failed send, and tells clients of new settings', async () => {notifications.send.mockRejectedValue(new Error('smtp down'));await expect(notify.bookingsPending(3, 2)).resolves.toBeUndefined();expect(notifications.send).toHaveBeenCalledWith(expect.objectContaining({ event: 'mail_booking_pending', params: { count: '2' } }),);expect(realtime.broadcastToUser).toHaveBeenCalledWith(3, { type: 'mailInbox:changed', pending: 2 });+ notify.settingsChanged(3);+ expect(realtime.broadcastToUser).toHaveBeenCalledWith(3, { type: 'mailInbox:settings' });});});