Skip to content

feat: Notifications#161

Open
alex289 wants to merge 20 commits into
mainfrom
feature/notification_backend
Open

feat: Notifications#161
alex289 wants to merge 20 commits into
mainfrom
feature/notification_backend

Conversation

@alex289
Copy link
Copy Markdown
Member

@alex289 alex289 commented May 12, 2026

Type of change

  • 🐛 Bug fix
  • 🚀 New feature
  • ❓ Other (please specify)

Description

Fixes #112

  • Add shouterrr
  • Add notifications to db
  • Add crud endpoints
  • Add tests
  • Add frontend

TODO:

  • list endpoints returning config?

@alex289 alex289 requested a review from timokoessler May 12, 2026 12:18
@alex289 alex289 self-assigned this May 12, 2026
Copilot AI review requested due to automatic review settings May 12, 2026 12:18
Copy link
Copy Markdown
Contributor

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

Adds a backend notifications feature backed by new DB tables and a Shoutrrr-based provider layer, exposing CRUD + test endpoints under /api/v1/notifications and adding unit/integration-style tests.

Changes:

  • Introduces notifications + application_notifications tables and GORM models/associations.
  • Adds REST endpoints to create/list/update/delete notifications and to send a test notification, with SSE update publishing.
  • Adds a notifications package with a provider registry (Discord implementation) and config parsing helpers, plus tests; updates Go deps to include Shoutrrr.

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
backend/internal/hub/routes/notifications.go New notifications CRUD + test handlers, request/response mapping, config normalization, app association loading
backend/internal/hub/routes/notifications_test.go Handler tests for list/create/update/delete/test endpoints
backend/internal/hub/notifications/provider/provider.go Provider interface + registry (Discord registered in init)
backend/internal/hub/notifications/provider/discord.go Discord config parsing and Shoutrrr URL construction (incl thread_id, username, avatar, title)
backend/internal/hub/notifications/provider/common.go Shared parsing for direct target configs and normalization/deduplication
backend/internal/hub/notifications/provider.go Public wrapper functions (Register/Get/Build*), keeps legacy BuildShoutrrrURLs
backend/internal/hub/notifications/notifications.go Notification dispatch + DB query selection logic + test-send helper
backend/internal/hub/notifications/notifications_test.go Tests for DB query filtering and config parsing/building
backend/internal/hub/models/notifications.go New Notification model and enums
backend/internal/hub/models/applications.go Adds many-to-many Notifications association on Application
backend/internal/hub/handlers.go Registers new protected notification routes
backend/internal/hub/db/migrations/000016_create_notifications_tables.up.sql Creates notifications + join table + indexes
backend/internal/hub/db/migrations/000016_create_notifications_tables.down.sql Drops notifications tables/indexes
backend/internal/hub/db/db_test.go Extends migration tests to assert new tables/columns exist
backend/go.mod Adds Shoutrrr dependency (and related indirect deps updates)
backend/go.sum Dependency checksum updates for new/updated modules

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

Comment thread backend/internal/hub/routes/notifications.go
Comment thread backend/internal/hub/routes/notifications.go
Comment thread backend/internal/hub/routes/notifications.go
Comment thread backend/internal/hub/routes/notifications.go
Comment thread backend/internal/hub/routes/notifications.go
Comment thread backend/internal/hub/routes/notifications.go
@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Comment thread backend/internal/hub/routes/notifications.go Outdated
Comment thread backend/internal/hub/routes/notifications.go Outdated
EnableByDefault *bool `json:"enableByDefault"`
Status models.NotificationStatus `json:"status" binding:"required"`
Type models.NotificationType `json:"type" binding:"required"`
Config json.RawMessage `json:"config" binding:"required"`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It might be possible to simplify the logic a lot by always using json for the config and always decode it just once and not in route handler and providers?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Im not sure what you mean by this

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think there are multiple places in the code where it checks if it's json and also allows non json? E.g. in parseDirectTargets in common.go?

Copy link
Copy Markdown
Member Author

@alex289 alex289 May 19, 2026

Choose a reason for hiding this comment

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

I tried improving it. Only the providers are parsing now which is necessary. Good enough?

@alex289 alex289 changed the title feat: Backend notifications feat: Notifications May 13, 2026
@github-actions github-actions Bot added the ci label May 19, 2026
@alex289 alex289 requested a review from timokoessler May 19, 2026 07:53
Comment thread frontend/package.json
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Image The modal is a bit large, long-term we can maybe do two steps or collapse additional optional settings, although it's also not nice to hide them.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The avatar and bot name can also be configured in Discord UI (with image upload). Not sure which of both settings has a higher priority? Maybe enough to just let the user configure them in Discord?

return "";
}

export default function UpsertNotificationDialog({
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In edit mode the dialog closes itself directly when the cursor moves away from the dropdown (at least in Firefox)

return nil, err
}

if strings.HasPrefix(trimmed, "{") {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We always send JSON from frontend to backend, or?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Configurable notifications

3 participants