Add Notification Filters for Seen and Priority

- Introduced new optional fields in the SearchForm for filtering notifications by 'seen' status and 'priority', enhancing the flexibility of notification retrieval.
- Updated the GetNotifications method in the notification service to accommodate the new filters, ensuring they are included in the query parameters.
- Enhanced the notification client to support the new filters in API requests, improving the overall functionality of the notification system.
- Updated API documentation with Swagger comments to reflect the new query parameters, ensuring clarity for API consumers.
This commit is contained in:
n.nakhostin
2025-09-22 09:57:14 +03:30
parent 928fab6b4a
commit aef91b4711
7 changed files with 66 additions and 4 deletions
+10 -4
View File
@@ -7,6 +7,7 @@ import (
"fmt"
"io"
"net/http"
"strings"
"time"
)
@@ -206,6 +207,8 @@ func (c *Client) GetNotifications(ctx context.Context, req *GetNotificationsRequ
"event_type": req.EventType,
"type": req.Type,
"user_id": req.UserID,
"seen": req.Seen,
"priority": req.Priority,
"base_url": c.config.BaseURL,
})
}
@@ -354,16 +357,19 @@ func (c *Client) buildQueryParams(req *GetNotificationsRequest) string {
if req.PerPage > 0 {
params = append(params, fmt.Sprintf("per_page=%d", req.PerPage))
}
if req.Seen != nil {
params = append(params, fmt.Sprintf("seen=%t", *req.Seen))
}
if req.Priority != "" {
params = append(params, fmt.Sprintf("priority=%s", req.Priority))
}
// Join parameters with &
if len(params) == 0 {
return ""
}
result := params[0]
for i := 1; i < len(params); i++ {
result += "&" + params[i]
}
result := strings.Join(params, "&")
return result
}
+2
View File
@@ -187,6 +187,8 @@ type GetNotificationsRequest struct {
EventType string `json:"event_type,omitempty" valid:"optional"`
Type string `json:"type,omitempty" valid:"optional"`
UserID string `json:"user_id,omitempty" valid:"optional"`
Seen *bool `json:"seen,omitempty" valid:"optional"`
Priority string `json:"priority,omitempty" valid:"optional"`
Page int `json:"page,omitempty" valid:"optional"`
PerPage int `json:"per_page,omitempty" valid:"optional"`
}