fix: use correct API endpoint for notification read

GitLink uses POST /users/{owner}/messages/read with ids array,
not PATCH on individual message. Fixed code and test accordingly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
15972095207 2026-06-04 09:42:26 +08:00
parent 97f9f63645
commit 49415faf54
2 changed files with 11 additions and 2 deletions

View File

@ -4,6 +4,8 @@ import (
"fmt"
"net/url"
"strconv"
"github.com/gitlink-org/gitlink-cli/shortcuts/common"
)
@ -69,7 +71,14 @@ func Shortcuts() []*common.Shortcut {
if err != nil {
return err
}
env, err := ctx.CallAPI("PATCH", fmt.Sprintf("/users/%s/messages/%s", login, id), nil)
idInt, err := strconv.Atoi(id)
if err != nil {
return fmt.Errorf("invalid id: %s", id)
}
body := map[string]interface{}{
"ids": []int{idInt},
}
env, err := ctx.CallAPI("POST", fmt.Sprintf("/users/%s/messages/read", login), body)
if err != nil {
return err
}

View File

@ -36,7 +36,7 @@ func TestNotificationView(t *testing.T) {
func TestNotificationRead(t *testing.T) {
server := newNotificationTestServer(t, func(w http.ResponseWriter, r *http.Request) {
assertRequest(t, r, "PATCH", "/users/testuser/messages/42.json")
assertRequest(t, r, "POST", "/users/testuser/messages/read.json")
writeJSON(t, w, map[string]interface{}{"status": 0, "message": "success"})
})
defer server.Close()