feat(notification): implement UpdateAdminNotification and rename admin RPCs - #2721
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR implements the admin “update draft notification” capability in the Notification service, including new admin-specific RPC/message names and REST paths, plus the storage/domain plumbing to persist updates.
Changes:
- Renames admin notification RPCs/messages to
*AdminNotification*and moves admin REST endpoints under/v1/admin_notification*(proto, gateway, swagger, proto.lock). - Adds storage read/update operations for admin notifications (MySQL/Postgres), including SQL for selecting/updating notifications and replacing localizations.
- Implements
UpdateAdminNotificationin the service layer, with request validation and transaction handling; adds domain-levelNotification.Update(...)helper and tests.
Reviewed changes
Copilot reviewed 18 out of 22 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| proto/proto.lock | Regenerates locked proto descriptors reflecting renamed admin RPCs/messages. |
| proto/notification/service.proto | Renames admin RPCs/messages and defines UpdateAdminNotification request/response schema and HTTP mappings. |
| proto/notification/service.pb.gw.go | Regenerates grpc-gateway handlers for new admin endpoints. |
| pkg/notification/storage/postgres/sql/update_notification.sql | Adds SQL to update last_edited_by and updated_at. |
| pkg/notification/storage/postgres/sql/select_notification.sql | Adds SQL to fetch a notification by id for admin update flow. |
| pkg/notification/storage/postgres/sql/delete_notification_localizations.sql | Adds SQL to delete localizations before full replacement. |
| pkg/notification/storage/postgres/notification.go | Adds GetAdminNotification and UpdateAdminNotification implementations and embeds new SQL. |
| pkg/notification/storage/postgres/notification_test.go | Adds unit tests for get/update admin notification storage behaviors. |
| pkg/notification/storage/notification.go | Extends NotificationStorage interface for admin get/update and adds unexpected-rows error. |
| pkg/notification/storage/mysql/sql/update_notification.sql | MySQL variant of update SQL. |
| pkg/notification/storage/mysql/sql/select_notification.sql | MySQL variant of select SQL. |
| pkg/notification/storage/mysql/sql/delete_notification_localizations.sql | MySQL variant of delete-localizations SQL. |
| pkg/notification/storage/mysql/notification.go | Adds GetAdminNotification and UpdateAdminNotification implementations and embeds new SQL. |
| pkg/notification/storage/mysql/notification_test.go | Adds unit tests for get/update admin notification storage behaviors. |
| pkg/notification/storage/mock/notification.go | Updates generated storage mock with new interface methods. |
| pkg/notification/domain/notification.go | Adds Notification.Update(...) helper to stamp editor/time and replace localizations. |
| pkg/notification/domain/notification_test.go | Adds unit test coverage for Notification.Update(...). |
| pkg/notification/api/error.go | Adds gRPC status helpers for id-required/not-found/already-published cases. |
| pkg/notification/api/api.go | Implements UpdateAdminNotification and refactors localization validation reuse. |
| pkg/notification/api/api_test.go | Adds service-level test coverage for update admin notification scenarios. |
| api-description/web-api.swagger.yaml | Updates swagger to expose new admin endpoints and schemas. |
Files not reviewed (2)
- pkg/notification/storage/mock/notification.go: Generated file
- proto/notification/service.pb.gw.go: Generated file
Comments suppressed due to low confidence (4)
pkg/notification/storage/postgres/notification_test.go:372
MockRow.Scanis called with 8 destination arguments inGetAdminNotification, but this expectation only provides a single matcher, so the gomock call won't match.
row := mock.NewMockRow(mockController)
row.EXPECT().Scan(gomock.Any()).DoAndReturn(func(args ...interface{}) error {
pkg/notification/storage/postgres/notification_test.go:505
UpdateAdminNotificationexecutesExecContextwith 3 SQL parameters (last_edited_by, updated_at, id), but this expectation only matches a single variadic argument, so the gomock call won't match.
s.qe.(*mock.MockQueryExecer).EXPECT().ExecContext(
gomock.Any(), updateNotificationSQL, gomock.Any(),
).Return(result, nil)
pkg/notification/storage/mysql/notification_test.go:372
MockRow.Scanis called with 8 destination arguments inGetAdminNotification, but this expectation only provides a single matcher, so the gomock call won't match.
row := mock.NewMockRow(mockController)
row.EXPECT().Scan(gomock.Any()).DoAndReturn(func(args ...interface{}) error {
pkg/notification/storage/mysql/notification_test.go:505
UpdateAdminNotificationexecutesExecContextwith 3 SQL parameters (last_edited_by, updated_at, id), but this expectation only matches a single variadic argument, so the gomock call won't match.
s.qe.(*mock.MockQueryExecer).EXPECT().ExecContext(
gomock.Any(), updateNotificationSQL, gomock.Any(),
).Return(result, nil)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
hvn2k1
marked this pull request as ready for review
July 27, 2026 04:24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #2215
What this PR does
Implements the
UpdateAdminNotificationRPC — system admins can edit a draft's localizations (tags, title, Markdown content); published notifications cannot be edited. It also renames the remaining admin RPCs to the*AdminNotificationconvention with/v1/admin_notification*routes, completing the split started byListDraftAdminNotifications(#2710).Background / Why this PR is needed
Continues the notification center backend (RFC 0047). The admin surface needed a consistent naming scheme separate from the viewer APIs before more admin RPCs land, so the rename ships together with the first RPC affected by it.
CreateAdminNotificationPOST /v1/admin_notificationUpdateAdminNotificationPATCH /v1/admin_notificationPublishAdminNotification(stub)POST /v1/admin_notification/publishDeleteAdminNotification(stub)DELETE /v1/admin_notificationViewer RPCs (
ListNotifications,GetNotification, unread count, mark-as-read) keep their/v1/notification(s)routes.Points
localizationsarray is a full replacement of the draft's localization set (delete-and-reinsert in one transaction), sharing the create API's validation viavalidateLocalizations.last_edited_byandupdated_atare stamped;created_by/created_atare untouched.GetAdminNotificationstorage method (single row + all localizations,COALESCEfor the nullablepublished_by) is intentionally reusable for the upcomingGetNotificationandPublishAdminNotificationimplementations.