-
Notifications
You must be signed in to change notification settings - Fork 943
feat(coderd): add inbox notifications endpoints #16889
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
3c6512b
c8ccc60
18b694b
0e8ac4c
d72d1f2
796bcd0
75c310d
07ab7c4
cb41d1a
6ff4c7e
1ebc7f4
736a2d7
c28002e
2637d86
4d0a561
1f18868
4f01a86
cf6af1b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,10 +34,10 @@ type GetInboxNotificationResponse struct { | |
} | ||
|
||
type ListInboxNotificationsRequest struct { | ||
defelmnq marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Targets string `json:"targets,omitempty"` | ||
Templates string `json:"templates,omitempty"` | ||
ReadStatus string `json:"read_status,omitempty" validate:"omitempty,oneof=read unread all"` | ||
StartingBefore uuid.UUID `json:"starting_before,omitempty" validate:"omitempty" format:"uuid"` | ||
Targets string `json:"targets,omitempty"` | ||
Templates string `json:"templates,omitempty"` | ||
ReadStatus string `json:"read_status,omitempty"` | ||
StartingBefore string `json:"starting_before,omitempty"` | ||
} | ||
|
||
type ListInboxNotificationsResponse struct { | ||
|
@@ -56,13 +56,28 @@ func ListInboxNotificationsRequestToQueryParams(req ListInboxNotificationsReques | |
if req.ReadStatus != "" { | ||
opts = append(opts, WithQueryParam("read_status", req.ReadStatus)) | ||
} | ||
if req.StartingBefore != uuid.Nil { | ||
opts = append(opts, WithQueryParam("starting_before", req.StartingBefore.String())) | ||
if req.StartingBefore != "" { | ||
opts = append(opts, WithQueryParam("starting_before", req.StartingBefore)) | ||
} | ||
|
||
return opts | ||
} | ||
|
||
func (c *Client) WatchInboxNotificationx(ctx context.Context) error { | ||
res, err := c.Request( | ||
ctx, http.MethodGet, | ||
"/api/v2/notifications/watch", | ||
nil, nil, | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
defer res.Body.Close() | ||
|
||
return nil | ||
} | ||
|
||
func (c *Client) ListInboxNotifications(ctx context.Context, req ListInboxNotificationsRequest) (ListInboxNotificationsResponse, error) { | ||
res, err := c.Request( | ||
ctx, http.MethodGet, | ||
|
@@ -91,7 +106,7 @@ type UpdateInboxNotificationReadStatusResponse struct { | |
UnreadCount int `json:"unread_count"` | ||
} | ||
|
||
func (c *Client) UpdateInboxNotificationReadStatus(ctx context.Context, notifID uuid.UUID, req UpdateInboxNotificationReadStatusRequest) (UpdateInboxNotificationReadStatusResponse, error) { | ||
func (c *Client) UpdateInboxNotificationReadStatus(ctx context.Context, notifID string, req UpdateInboxNotificationReadStatusRequest) (UpdateInboxNotificationReadStatusResponse, error) { | ||
res, err := c.Request( | ||
ctx, http.MethodPut, | ||
fmt.Sprintf("/api/v2/notifications/inbox/%v/read-status", notifID), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Alternatively, we can change this to PS. Ignore this if it is too late to change the API. |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whenever you log a message, I want you to think to yourself: "If I were an operator, how would I know what happened here, why I should care, and what to do next". This doesn't really satisfy any of those 3 clauses.