Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 534213f10e | |||
| 6d5694977b |
@@ -0,0 +1 @@
|
|||||||
|
* text=auto
|
||||||
@@ -30,6 +30,7 @@ type SearchForm struct {
|
|||||||
EventType string `query:"event_type" valid:"optional"`
|
EventType string `query:"event_type" valid:"optional"`
|
||||||
Type string `query:"type" valid:"optional"`
|
Type string `query:"type" valid:"optional"`
|
||||||
Recipient []string `query:"recipient" json:"recipient" valid:"optional"`
|
Recipient []string `query:"recipient" json:"recipient" valid:"optional"`
|
||||||
|
UserID string `query:"user_id" valid:"optional"`
|
||||||
Seen *bool `query:"seen" valid:"optional"`
|
Seen *bool `query:"seen" valid:"optional"`
|
||||||
Priority string `query:"priority" valid:"optional"`
|
Priority string `query:"priority" valid:"optional"`
|
||||||
}
|
}
|
||||||
@@ -45,6 +46,14 @@ func (f *SearchForm) ResolvedSearch() string {
|
|||||||
return ""
|
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 {
|
type NotificationListResponse struct {
|
||||||
Notifications []*NotificationResponse `json:"notifications"`
|
Notifications []*NotificationResponse `json:"notifications"`
|
||||||
Meta *response.Meta `json:"meta"`
|
Meta *response.Meta `json:"meta"`
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ func (h *NotificationHandler) Send(c echo.Context) error {
|
|||||||
// @Param event_type query string false "Event type filter"
|
// @Param event_type query string false "Event type filter"
|
||||||
// @Param type query string false "Type filter"
|
// @Param type query string false "Type filter"
|
||||||
// @Param recipient query string false "Recipient filter"
|
// @Param recipient query string false "Recipient filter"
|
||||||
|
// @Param user_id query string false "User ID filter"
|
||||||
// @Param seen query bool false "Seen filter"
|
// @Param seen query bool false "Seen filter"
|
||||||
// @Param priority query string false "Priority filter"
|
// @Param priority query string false "Priority filter"
|
||||||
// @Param limit query int false "Limit results"
|
// @Param limit query int false "Limit results"
|
||||||
|
|||||||
@@ -197,14 +197,14 @@ func (s *notificationService) GetNotifications(ctx context.Context, req *SearchF
|
|||||||
"method": req.Method,
|
"method": req.Method,
|
||||||
"event_type": req.EventType,
|
"event_type": req.EventType,
|
||||||
"type": req.Type,
|
"type": req.Type,
|
||||||
"recipient": req.Recipient,
|
"recipient": req.ResolvedRecipients(),
|
||||||
"seen": req.Seen,
|
"seen": req.Seen,
|
||||||
"priority": req.Priority,
|
"priority": req.Priority,
|
||||||
"limit": pagination.Limit,
|
"limit": pagination.Limit,
|
||||||
"offset": pagination.Offset,
|
"offset": pagination.Offset,
|
||||||
})
|
})
|
||||||
|
|
||||||
page, err := s.repository.GetByUserID(ctx, req.Recipient, search, req.Status, req.Seen, req.Priority, req.EventType, req.Type, pagination)
|
page, err := s.repository.GetByUserID(ctx, req.ResolvedRecipients(), search, req.Status, req.Seen, req.Priority, req.EventType, req.Type, pagination)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.logger.Error("Failed to get notifications", map[string]interface{}{
|
s.logger.Error("Failed to get notifications", map[string]interface{}{
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
|
|||||||
Reference in New Issue
Block a user