fix: keep workbench user ids compatible

This commit is contained in:
richjohnrambo
2026-09-16 18:02:19 +08:00
parent 5789b85663
commit 903a77f2c5
4 changed files with 163 additions and 30 deletions
+33
View File
@@ -0,0 +1,33 @@
package httpapi
import (
"encoding/json"
"testing"
)
func TestUserIDJSONAcceptsIMUserID(t *testing.T) {
var body struct {
RecorderUserID userID `json:"recorder_user_id"`
AttendeeUserIDs []userID `json:"attendee_user_ids"`
}
raw := []byte(`{"recorder_user_id":"usrag7w9xJ6hto","attendee_user_ids":["usr1RqTFgHSenM"]}`)
if err := json.Unmarshal(raw, &body); err != nil {
t.Fatalf("unmarshal: %v", err)
}
if body.RecorderUserID == 0 || len(body.AttendeeUserIDs) != 1 || body.AttendeeUserIDs[0] == 0 {
t.Fatalf("decoded zero ids: %+v", body)
}
if got := formatUserID(int64(body.RecorderUserID)); got != "usrag7w9xJ6hto" {
t.Fatalf("roundtrip recorder=%q", got)
}
}
func TestUserIDJSONStillAcceptsNumericID(t *testing.T) {
var id userID
if err := json.Unmarshal([]byte(`1573862062872858624`), &id); err != nil {
t.Fatalf("unmarshal numeric: %v", err)
}
if id != 1573862062872858624 {
t.Fatalf("id=%d", id)
}
}