Enhance notification search functionality with user ID filtering
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
- Added a new `UserID` field to the `SearchForm` to allow filtering notifications by user ID. - Implemented the `ResolvedRecipients` method to return user IDs based on the `user_id` or `recipient` query parameters, improving the flexibility of notification searches. - Updated the `GetNotifications` method in the service layer to utilize the new recipient resolution logic, ensuring accurate retrieval of notifications based on user ID. This update enhances the notification management capabilities, providing more granular control over notification searches.
This commit is contained in:
@@ -30,6 +30,7 @@ type SearchForm struct {
|
||||
EventType string `query:"event_type" valid:"optional"`
|
||||
Type string `query:"type" valid:"optional"`
|
||||
Recipient []string `query:"recipient" json:"recipient" valid:"optional"`
|
||||
UserID string `query:"user_id" valid:"optional"`
|
||||
Seen *bool `query:"seen" valid:"optional"`
|
||||
Priority string `query:"priority" valid:"optional"`
|
||||
}
|
||||
@@ -45,6 +46,14 @@ func (f *SearchForm) ResolvedSearch() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// ResolvedRecipients returns the user IDs to filter by from user_id or recipient query params.
|
||||
func (f *SearchForm) ResolvedRecipients() []string {
|
||||
if id := strings.TrimSpace(f.UserID); id != "" {
|
||||
return []string{id}
|
||||
}
|
||||
return f.Recipient
|
||||
}
|
||||
|
||||
type NotificationListResponse struct {
|
||||
Notifications []*NotificationResponse `json:"notifications"`
|
||||
Meta *response.Meta `json:"meta"`
|
||||
|
||||
Reference in New Issue
Block a user