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:
@@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"project_info": {
|
||||||
|
"project_number": "6923326255",
|
||||||
|
"project_id": "opplens-270d1",
|
||||||
|
"storage_bucket": "opplens-270d1.firebasestorage.app"
|
||||||
|
},
|
||||||
|
"client": [
|
||||||
|
{
|
||||||
|
"client_info": {
|
||||||
|
"mobilesdk_app_id": "1:6923326255:android:6704c5b71e4451abed87da",
|
||||||
|
"android_client_info": {
|
||||||
|
"package_name": "com.opplens.app"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"oauth_client": [],
|
||||||
|
"api_key": [
|
||||||
|
{
|
||||||
|
"current_key": "AIzaSyCqZ6B5iih0RdFj0lf5_erwbZvMyb7obEg"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"services": {
|
||||||
|
"appinvite_service": {
|
||||||
|
"other_platform_oauth_client": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"configuration_version": "1"
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"type": "service_account",
|
||||||
|
"project_id": "opplens-270d1",
|
||||||
|
"private_key_id": "c93fc2059648add37b362e57c5e08c1da052eb9f",
|
||||||
|
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDcSxjuz+/NmjqG\nDPhgKoexDYOQVDopQOEHR/oPk9lLKMwja9AAjRPXNAx4iRPFVJoylbNeqo9sPO0U\nxUTJ1gkGLNSewpMOpFSGKw5M1Tv7A907+31CjK8qNZEi+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rA96u5hLc9CyDn2+F0iC9YoSBduMnfJlIT46SOG9qwpQKBgQC1\noxB+agWzqjZsEcBo6CuTpm+3k7URt9AdL0ISBRE/CjUydfv54DStwqusJMuiZKyh\nKixGwuTGX03wYwxGLwf7Go46XPq5rhcRmtw15t9COwBTu+duyAYtxxI87boyvv/P\nNZUpk80bZvjXNwC4LtYO0HfQuovUGWF7rQGoXtolTQKBgGP+8wE05w69LqatmAMJ\nlfZsBpbFcZJJ3E0fJ8jzSguqWVBGGpvry2l3DSlIFIoDx1sg//jTgvTangnnAOsn\n6gGz0lsPTn9w6KKOJuDEbNUVQdFlcHE/9gEr1RIUS5dnHCJRL5GDr4VsmB9lwhR/\nA2HfPXE2lGGNaqcUB9PVhPHl\n-----END PRIVATE KEY-----\n",
|
||||||
|
"client_email": "firebase-adminsdk-fbsvc@opplens-270d1.iam.gserviceaccount.com",
|
||||||
|
"client_id": "108524830678171284272",
|
||||||
|
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
||||||
|
"token_uri": "https://oauth2.googleapis.com/token",
|
||||||
|
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
||||||
|
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-fbsvc%40opplens-270d1.iam.gserviceaccount.com",
|
||||||
|
"universe_domain": "googleapis.com"
|
||||||
|
}
|
||||||
@@ -26,6 +26,8 @@ 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" valid:"optional"`
|
Recipient string `query:"recipient" valid:"optional"`
|
||||||
|
Seen *bool `query:"seen" valid:"optional"`
|
||||||
|
Priority string `query:"priority" valid:"optional"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type NotificationListResponse struct {
|
type NotificationListResponse struct {
|
||||||
|
|||||||
@@ -64,6 +64,8 @@ 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 seen query bool false "Seen filter"
|
||||||
|
// @Param priority query string false "Priority filter"
|
||||||
// @Param limit query int false "Limit results"
|
// @Param limit query int false "Limit results"
|
||||||
// @Param offset query int false "Offset results"
|
// @Param offset query int false "Offset results"
|
||||||
// @Param sort_by query string false "Sort field"
|
// @Param sort_by query string false "Sort field"
|
||||||
@@ -108,6 +110,8 @@ func (h *NotificationHandler) GetNotifications(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 seen query bool false "Seen filter"
|
||||||
|
// @Param priority query string false "Priority filter"
|
||||||
// @Param limit query int false "Limit results"
|
// @Param limit query int false "Limit results"
|
||||||
// @Param offset query int false "Offset results"
|
// @Param offset query int false "Offset results"
|
||||||
// @Param sort_by query string false "Sort field"
|
// @Param sort_by query string false "Sort field"
|
||||||
@@ -219,6 +223,8 @@ func (h *NotificationHandler) ViewNotification(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 seen query bool false "Seen filter"
|
||||||
|
// @Param priority query string false "Priority filter"
|
||||||
// @Param limit query int false "Limit results"
|
// @Param limit query int false "Limit results"
|
||||||
// @Param offset query int false "Offset results"
|
// @Param offset query int false "Offset results"
|
||||||
// @Param sort_by query string false "Sort field"
|
// @Param sort_by query string false "Sort field"
|
||||||
|
|||||||
@@ -165,6 +165,8 @@ func (s *notificationService) GetNotifications(ctx context.Context, req *SearchF
|
|||||||
"event_type": req.EventType,
|
"event_type": req.EventType,
|
||||||
"type": req.Type,
|
"type": req.Type,
|
||||||
"recipient": req.Recipient,
|
"recipient": req.Recipient,
|
||||||
|
"seen": req.Seen,
|
||||||
|
"priority": req.Priority,
|
||||||
"limit": pagination.Limit,
|
"limit": pagination.Limit,
|
||||||
"offset": pagination.Offset,
|
"offset": pagination.Offset,
|
||||||
})
|
})
|
||||||
@@ -175,6 +177,8 @@ func (s *notificationService) GetNotifications(ctx context.Context, req *SearchF
|
|||||||
EventType: req.EventType,
|
EventType: req.EventType,
|
||||||
Type: req.Type,
|
Type: req.Type,
|
||||||
UserID: req.Recipient,
|
UserID: req.Recipient,
|
||||||
|
Seen: req.Seen,
|
||||||
|
Priority: req.Priority,
|
||||||
PerPage: pagination.Limit,
|
PerPage: pagination.Limit,
|
||||||
Page: pagination.Offset / pagination.Limit,
|
Page: pagination.Offset / pagination.Limit,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -206,6 +207,8 @@ func (c *Client) GetNotifications(ctx context.Context, req *GetNotificationsRequ
|
|||||||
"event_type": req.EventType,
|
"event_type": req.EventType,
|
||||||
"type": req.Type,
|
"type": req.Type,
|
||||||
"user_id": req.UserID,
|
"user_id": req.UserID,
|
||||||
|
"seen": req.Seen,
|
||||||
|
"priority": req.Priority,
|
||||||
"base_url": c.config.BaseURL,
|
"base_url": c.config.BaseURL,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -354,16 +357,19 @@ func (c *Client) buildQueryParams(req *GetNotificationsRequest) string {
|
|||||||
if req.PerPage > 0 {
|
if req.PerPage > 0 {
|
||||||
params = append(params, fmt.Sprintf("per_page=%d", req.PerPage))
|
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 &
|
// Join parameters with &
|
||||||
if len(params) == 0 {
|
if len(params) == 0 {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
result := params[0]
|
result := strings.Join(params, "&")
|
||||||
for i := 1; i < len(params); i++ {
|
|
||||||
result += "&" + params[i]
|
|
||||||
}
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -187,6 +187,8 @@ type GetNotificationsRequest struct {
|
|||||||
EventType string `json:"event_type,omitempty" valid:"optional"`
|
EventType string `json:"event_type,omitempty" valid:"optional"`
|
||||||
Type string `json:"type,omitempty" valid:"optional"`
|
Type string `json:"type,omitempty" valid:"optional"`
|
||||||
UserID string `json:"user_id,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"`
|
Page int `json:"page,omitempty" valid:"optional"`
|
||||||
PerPage int `json:"per_page,omitempty" valid:"optional"`
|
PerPage int `json:"per_page,omitempty" valid:"optional"`
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user