Skip to content

feat(stalwart): add Stalwart webhook integration with authentication …#65

Merged
jzunigax2 merged 5 commits into
masterfrom
feat/stalwart-events-webhook
Jun 30, 2026
Merged

feat(stalwart): add Stalwart webhook integration with authentication …#65
jzunigax2 merged 5 commits into
masterfrom
feat/stalwart-events-webhook

Conversation

@jzunigax2

Copy link
Copy Markdown
Contributor
  • Introduced Stalwart webhook configuration in .env.template.
  • Added StalwartEventsModule, including controller, service, and authentication guard.
  • Implemented event handling logic for Stalwart webhook events.
  • Configured authentication using Basic Auth with credentials from environment variables.

This integration allows the application to process events from Stalwart's webhook

@jzunigax2 jzunigax2 force-pushed the feat/stalwart-events-webhook branch from 6ac1b18 to 17a2fce Compare June 16, 2026 04:23
@jzunigax2 jzunigax2 changed the base branch from feat/store-stalwart-account-id to feat/create-bucket-on-account-provisioning June 16, 2026 04:24
@jzunigax2 jzunigax2 changed the base branch from feat/create-bucket-on-account-provisioning to master June 17, 2026 05:21
@jzunigax2 jzunigax2 changed the base branch from master to feat/create-bucket-on-account-provisioning June 17, 2026 05:22
@jzunigax2 jzunigax2 force-pushed the feat/stalwart-events-webhook branch 2 times, most recently from 8240a10 to 96cf7aa Compare June 24, 2026 14:06
@jzunigax2 jzunigax2 force-pushed the feat/create-bucket-on-account-provisioning branch from dfc264e to 0712a8b Compare June 30, 2026 13:39
Base automatically changed from feat/create-bucket-on-account-provisioning to master June 30, 2026 14:42
@jzunigax2 jzunigax2 requested a review from xabg2 June 30, 2026 14:42
@jzunigax2 jzunigax2 self-assigned this Jun 30, 2026
- Introduced a new column `network_bucket_id` in the `mail_accounts` table to associate accounts with network buckets.
- Updated `AccountService` to create and delete mail buckets via the BridgeClient.
- Enhanced unit tests to cover new functionality related to network bucket management.
- Modified relevant models and repositories to handle the new `networkBucketId` attribute.
…and event handling

- Introduced Stalwart webhook configuration in .env.template.
- Added StalwartEventsModule, including controller, service, and authentication guard.
- Implemented event handling logic for Stalwart webhook events.
- Configured authentication using Basic Auth with credentials from environment variables.

This integration allows the application to process events from Stalwart's webhook securely.
- Added `findBucketContextByProviderInternalId` method to `AddressRepository` for resolving user and bucket context.
- Updated `AccountService` to delete provider links during account provisioning failure.
- Implemented `createBucketEntry` method in `BridgeClient` for creating bucket entries in response to Stalwart events.
- Enhanced `StalwartEventsService` to handle batch events and create bucket entries based on resolved account context.
- Added unit tests for the new functionality in `StalwartEventsService` and `AddressRepository` to ensure proper behavior.
- Updated `deleteEmail` method in `EmailService` to handle quota entry release upon email deletion.
- Introduced `releaseQuotaEntry` method to manage quota entries based on email deletion results.
- Modified `deleteEmail` in `MailProvider` to return a result object containing the deleted entry key.
- Enhanced unit tests for `EmailService` and `JmapMailProvider` to cover new deletion behavior and quota management scenarios.
- Integrated `BridgeClient` for handling quota entry deletions in the bridge service.
- Introduced `decodeStalwartIdBig` function to handle Stalwart IDs exceeding JavaScript's safe integer range, allowing for proper decoding of email IDs.
- Updated `decodeStalwartId` to utilize the new decoding function and throw an error for IDs exceeding safe integer limits.
- Enhanced `StalwartEventsAuthGuard` to throw an `UnauthorizedException` for malformed authorization headers lacking a colon separator.
- Added unit tests for the new decoding function and authentication guard to ensure robust error handling and functionality.
@jzunigax2 jzunigax2 force-pushed the feat/stalwart-events-webhook branch from 96cf7aa to 2a9c787 Compare June 30, 2026 14:54
@jzunigax2 jzunigax2 marked this pull request as ready for review June 30, 2026 14:55
@sonarqubecloud

Copy link
Copy Markdown

Comment on lines +20 to +22
if (event.type === 'message-ingest.duplicate') {
continue;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No needed, it can be handled for the next if

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

hmm not really. the next if checks for events that do not start with message-ingest while this one skips over message-ingest.duplicate ones

@jzunigax2 jzunigax2 merged commit 176b48c into master Jun 30, 2026
5 checks passed
@jzunigax2 jzunigax2 deleted the feat/stalwart-events-webhook branch June 30, 2026 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants