feat(routes): expand account parity coverage

This commit is contained in:
2026-06-04 20:44:20 +08:00
parent 14fa51d0b6
commit 14e784c51d
7 changed files with 253 additions and 20 deletions
@@ -57,7 +57,7 @@ func (h *NotificationHandler) Get(c *gin.Context) {
response.AbortWithStatusError(c, http.StatusServiceUnavailable, response.ErrInternal, "Notification service not available")
return
}
notificationID, err := parseUintParam(c, "notification_id")
notificationID, err := parseUintAnyParam(c, "notification_id", "id")
if err != nil {
response.AbortWithStatusError(c, http.StatusBadRequest, response.ErrBadRequest, "invalid notification id")
return
@@ -76,7 +76,7 @@ func (h *NotificationHandler) Get(c *gin.Context) {
// PUT /api/v1/accounts/:account_id/notifications/:id
// Reference: Chatwoot update — @notification.update(read_at: DateTime.now.utc); render json: @notification
func (h *NotificationHandler) Update(c *gin.Context) {
notificationID, err := parseUintParam(c, "notification_id")
notificationID, err := parseUintAnyParam(c, "notification_id", "id")
if err != nil {
response.AbortWithStatusError(c, http.StatusBadRequest, response.ErrBadRequest, "invalid notification id")
return
@@ -134,7 +134,7 @@ func (h *NotificationHandler) UnreadCount(c *gin.Context) {
// POST /api/v1/accounts/:account_id/notifications/:id/snooze
// Reference: Chatwoot snooze — update(snoozed_until: ..., meta: ...)
func (h *NotificationHandler) Snooze(c *gin.Context) {
notificationID, err := parseUintParam(c, "notification_id")
notificationID, err := parseUintAnyParam(c, "notification_id", "id")
if err != nil {
response.AbortWithStatusError(c, http.StatusBadRequest, response.ErrBadRequest, "invalid notification id")
return
@@ -170,7 +170,7 @@ func (h *NotificationHandler) Snooze(c *gin.Context) {
// POST /api/v1/accounts/:account_id/notifications/:id/unread
// Reference: Chatwoot unread — @notification.update(read_at: nil); render json: @notification
func (h *NotificationHandler) Unread(c *gin.Context) {
notificationID, err := parseUintParam(c, "notification_id")
notificationID, err := parseUintAnyParam(c, "notification_id", "id")
if err != nil {
response.AbortWithStatusError(c, http.StatusBadRequest, response.ErrBadRequest, "invalid notification id")
return
@@ -192,7 +192,7 @@ func (h *NotificationHandler) Unread(c *gin.Context) {
// DELETE /api/v1/accounts/:account_id/notifications/:id
// Reference: Chatwoot destroy — @notification.destroy; head :ok
func (h *NotificationHandler) Destroy(c *gin.Context) {
notificationID, err := parseUintParam(c, "notification_id")
notificationID, err := parseUintAnyParam(c, "notification_id", "id")
if err != nil {
response.AbortWithStatusError(c, http.StatusBadRequest, response.ErrBadRequest, "invalid notification id")
return
@@ -225,4 +225,4 @@ func (h *NotificationHandler) DestroyAll(c *gin.Context) {
}
c.Status(http.StatusOK)
}
}