Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp

feat(api): drop waitlist emails that bounce or unsubscribe

Hampus1b49aab35d81
diff --git a/fluxer_api/src/api/webhook/SweegoWebhookService.ts b/fluxer_api/src/api/webhook/SweegoWebhookService.ts
index 85d625e90..5b5985f37 100644
--- a/fluxer_api/src/api/webhook/SweegoWebhookService.ts
+++ b/fluxer_api/src/api/webhook/SweegoWebhookService.ts
@@ -16,6 +16,10 @@ interface ISweegoUserRepository {
patchUpsert(userId: UserID, patch: Partial<UserRow>, currentRow: UserRow): Promise<User | null>;
}
+interface ISweegoWaitlistSuppression {
+ suppress(email: string, reason: 'bounced' | 'unsubscribed'): Promise<boolean>;
+}
+
interface ISweegoGatewayService {
dispatchPresence(params: {userId: UserID; event: GatewayDispatchEvent; data: unknown}): Promise<void>;
}
@@ -70,6 +74,7 @@ export class SweegoWebhookService {
constructor(
private readonly userRepository: ISweegoUserRepository,
private readonly gatewayService: ISweegoGatewayService,
+ private readonly waitlist: ISweegoWaitlistSuppression | null = null,
) {}
verifySignature(body: string, webhookId: string, timestamp: string, signature: string, secret: string): boolean {
@@ -124,11 +129,16 @@ export class SweegoWebhookService {
}
async processEvent(event: SweegoEvent): Promise<void> {
+ if (event.event_type === 'list_unsub') {
+ await this.suppressWaitlistEntry(event, 'unsubscribed');
+ return;
+ }
if (event.event_type !== 'soft-bounce' && event.event_type !== 'hard_bounce' && event.event_type !== 'complaint') {
Logger.debug({eventType: event.event_type, recipient: event.recipient}, 'Sweego event received (ignored)');
return;
}
if (event.event_type === 'hard_bounce' || event.event_type === 'complaint') {
+ await this.suppressWaitlistEntry(event, 'bounced');
await this.handleHardBounceOrComplaint(event);
return;
}
@@ -138,6 +148,10 @@ export class SweegoWebhookService {
);
}
+ private async suppressWaitlistEntry(event: SweegoEvent, reason: 'bounced' | 'unsubscribed'): Promise<void> {
+ await this.waitlist?.suppress(event.recipient, reason);
+ }
+
private async handleHardBounceOrComplaint(event: SweegoEvent): Promise<void> {
Logger.warn(
{