Skip to content

[FEAT] implement email service send emails for workspace invitations#21

Merged
martian56 merged 4 commits intomainfrom
20-implement-email-service-send-emails-for-workspace-invitations
Mar 9, 2026
Merged

[FEAT] implement email service send emails for workspace invitations#21
martian56 merged 4 commits intomainfrom
20-implement-email-service-send-emails-for-workspace-invitations

Conversation

@martian56
Copy link
Member

This pull request introduces a complete backend and partial frontend implementation for public workspace invite links, including email delivery and invite management. The changes add support for generating, sending, and handling workspace invitations via unique tokens, and ensure robust email delivery with logging and configuration via instance settings. Additionally, it introduces a new API for invite token handling and improves the email queue and logging flows.

The most important changes are:

Workspace Invitation System & API:

  • Added new InvitationHandler in api/internal/handler/invitation.go with public endpoints to fetch invite details by token and to decline an invite, enabling the frontend to support invite acceptance and decline flows.
  • Registered new public invite endpoints in the router (/api/invitations/by-token/ and /api/invitations/decline/).
  • Added new API response type InviteByTokenResponse for invite token lookup in the frontend API types.

Email Delivery and Logging:

  • Introduced a new SMTP email sender in api/internal/mail/mail.go that loads SMTP settings from instance settings, sends emails, and logs all attempts, successes, failures, and skips.
  • Added detailed structured logging for email delivery attempts, successes, failures, and skips in api/internal/mail/logger.go.
  • Updated the queue consumer to log email delivery attempts and results, including invite URLs, and to use the new SMTP sender. [1] [2] [3]

Workspace Invite Email Flow:

  • Modified WorkspaceHandler to enqueue workspace invite emails with a proper invite link using the configured frontend base URL, and to include additional context in the queue payload. [1] [2]
  • Extended the queue payload (SendEmailPayload) to include an optional invite_url field for logging and debugging.

Configuration and Environment:

  • Added APP_BASE_URL to .env.example and configuration structs, allowing the backend to generate correct invite links for emails. If unset, falls back to CORS_ORIGIN. [1] [2] [3] [4] [5]

Frontend Improvements:

  • Added an interceptor in the API client to correctly handle FormData uploads by omitting the Content-Type header, preventing server-side parsing errors.
  • Bumped UI version numbers to 0.3.2. [1] [2]

Closes #20

@martian56 martian56 added this to the Deadline milestone Mar 9, 2026
@martian56 martian56 self-assigned this Mar 9, 2026
Copilot AI review requested due to automatic review settings March 9, 2026 01:00
@martian56 martian56 added enhancement New feature or request API UI labels Mar 9, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements the email service for workspace invitations (closes #20). It adds a complete backend flow for generating, sending, and handling workspace invitations via unique tokens, with SMTP email delivery and structured logging. The frontend gains new pages for accepting/declining invites and signing up via invite links, plus improvements to the settings page for managing pending invites.

Changes:

  • Added backend SMTP email sender, email logging, and queue consumer integration for sending workspace invitation emails with configurable APP_BASE_URL.
  • Created new public API endpoints (/api/invitations/by-token/ and /api/invitations/decline/) and frontend pages (InviteAcceptPage, InviteSignUpPage) for the invite acceptance flow.
  • Updated the frontend with theme-aware styling fixes (replacing hardcoded bg-white with CSS custom properties), a FormData upload interceptor, pending invite context menus in settings, and sign-up integration via the auth service.

Reviewed changes

Copilot reviewed 23 out of 24 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
api/internal/handler/invitation.go New handler for public invite token lookup and decline endpoints
api/internal/handler/workspace.go Enqueues invite emails after creating workspace invitations
api/internal/mail/mail.go New SMTP email sender loading config from instance settings
api/internal/mail/logger.go Structured logging helpers for email delivery lifecycle
api/internal/queue/queue.go Extended SendEmailPayload with optional invite_url
api/internal/queue/consumer.go Updated email handler with logging and new sender signature
api/internal/router/router.go Registered public invite endpoints and updated workspace handler init
api/internal/config/config.go Added AppBaseURL config field
api/cmd/api/main.go Wired up SMTP email sender and instance settings store
api/.env.example Added APP_BASE_URL environment variable
ui/src/pages/InviteAcceptPage.tsx New page for invite token acceptance/decline flow
ui/src/pages/InviteSignUpPage.tsx New page for sign-up via invite token
ui/src/pages/LoginPage.tsx Enhanced to support prefilled email and return-to-invite flow
ui/src/pages/SettingsPage.tsx Added context menu for pending invites (copy link, remove)
ui/src/pages/ProfilePage.tsx Theme-aware styling (bg-white → CSS custom properties)
ui/src/services/invitationService.ts New service for public invitation APIs
ui/src/services/workspaceService.ts Added joinByToken method
ui/src/services/authService.ts Added signUp method
ui/src/api/types.ts Added InviteByTokenResponse type
ui/src/api/client.ts FormData Content-Type interceptor
ui/src/routes/index.tsx Registered invite and sign-up routes
ui/src/styles/tokens.css Updated --bg-canvas token
ui/package.json / ui/package-lock.json Version bump to 0.3.2
Files not reviewed (1)
  • ui/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@martian56 martian56 merged commit 8ef4d38 into main Mar 9, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API enhancement New feature or request UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Email service & Send emails for workspace invitations

2 participants