fix: keep workbench user ids compatible
This commit is contained in:
+19
-19
@@ -238,7 +238,7 @@ func (a *API) attendanceRecords(w http.ResponseWriter, r *http.Request, p *auth.
|
||||
Status: r.URL.Query().Get("status"),
|
||||
Cursor: r.URL.Query().Get("cursor"),
|
||||
Limit: limit(r, 50, 100),
|
||||
UserID: parseInt64(r.URL.Query().Get("user_id")),
|
||||
UserID: parseUserIDQuery(r.URL.Query().Get("user_id")),
|
||||
})
|
||||
if err != nil {
|
||||
writeStoreError(w, r, err)
|
||||
@@ -401,13 +401,13 @@ func (a *API) meetings(w http.ResponseWriter, r *http.Request, p *auth.Principal
|
||||
return
|
||||
}
|
||||
var body struct {
|
||||
Title string `json:"title"`
|
||||
RecorderUserID int64 `json:"recorder_user_id"`
|
||||
StartAt string `json:"start_at"`
|
||||
EndAt string `json:"end_at"`
|
||||
Location string `json:"location"`
|
||||
AttendeeUserIDs []int64 `json:"attendee_user_ids"`
|
||||
ReminderMinutes []int `json:"reminder_minutes"`
|
||||
Title string `json:"title"`
|
||||
RecorderUserID userID `json:"recorder_user_id"`
|
||||
StartAt string `json:"start_at"`
|
||||
EndAt string `json:"end_at"`
|
||||
Location string `json:"location"`
|
||||
AttendeeUserIDs []userID `json:"attendee_user_ids"`
|
||||
ReminderMinutes []int `json:"reminder_minutes"`
|
||||
}
|
||||
if !decodeBody(w, r, &body) {
|
||||
return
|
||||
@@ -424,9 +424,9 @@ func (a *API) meetings(w http.ResponseWriter, r *http.Request, p *auth.Principal
|
||||
}
|
||||
reminders, _ := json.Marshal(body.ReminderMinutes)
|
||||
meeting, err := a.store.CreateMeeting(r.Context(), p.UserID, store.Meeting{
|
||||
MeetingID: "mtg_" + randomToken(12), RecorderID: body.RecorderUserID, Title: strings.TrimSpace(body.Title), StartAt: startAt, EndAt: endAt,
|
||||
MeetingID: "mtg_" + randomToken(12), RecorderID: int64(body.RecorderUserID), Title: strings.TrimSpace(body.Title), StartAt: startAt, EndAt: endAt,
|
||||
Location: strings.TrimSpace(body.Location), ReminderMinutes: string(reminders), IdempotencyKey: idempotencyKey,
|
||||
}, body.AttendeeUserIDs)
|
||||
}, parseUserIDList(body.AttendeeUserIDs))
|
||||
if err != nil {
|
||||
writeStoreError(w, r, err)
|
||||
return
|
||||
@@ -459,14 +459,14 @@ func (a *API) meetingResource(w http.ResponseWriter, r *http.Request, p *auth.Pr
|
||||
writeSuccess(w, r, meetingPayload(*meeting, p.UserID))
|
||||
case tail == "" && r.Method == http.MethodPatch:
|
||||
var body struct {
|
||||
Title *string `json:"title"`
|
||||
RecorderUserID *int64 `json:"recorder_user_id"`
|
||||
Version int `json:"version"`
|
||||
Title *string `json:"title"`
|
||||
RecorderUserID optionalUserID `json:"recorder_user_id"`
|
||||
Version int `json:"version"`
|
||||
}
|
||||
if !decodeBody(w, r, &body) {
|
||||
return
|
||||
}
|
||||
meeting, err := a.store.UpdateMeeting(r.Context(), p.UserID, meetingID, store.MeetingPatch{Title: body.Title, RecorderID: body.RecorderUserID, Version: body.Version})
|
||||
meeting, err := a.store.UpdateMeeting(r.Context(), p.UserID, meetingID, store.MeetingPatch{Title: body.Title, RecorderID: body.RecorderUserID.ptr(), Version: body.Version})
|
||||
if err != nil {
|
||||
writeStoreError(w, r, err)
|
||||
return
|
||||
@@ -729,14 +729,14 @@ func (a *API) dailyReportReminders(w http.ResponseWriter, r *http.Request, p *au
|
||||
return
|
||||
}
|
||||
var body struct {
|
||||
Date string `json:"date"`
|
||||
UserIDs []int64 `json:"user_ids"`
|
||||
Date string `json:"date"`
|
||||
UserIDs []userID `json:"user_ids"`
|
||||
}
|
||||
if !decodeBody(w, r, &body) {
|
||||
return
|
||||
}
|
||||
if !a.publishWorkbenchEvent(w, r, p, "daily_report", "daily_report.reminded", strings.TrimSpace(body.Date),
|
||||
body.UserIDs, "日报提醒", strings.TrimSpace(body.Date),
|
||||
parseUserIDList(body.UserIDs), "日报提醒", strings.TrimSpace(body.Date),
|
||||
map[string]any{"date": strings.TrimSpace(body.Date), "idempotency_key": idempotencyKey, "reminded_count": len(body.UserIDs)}) {
|
||||
return
|
||||
}
|
||||
@@ -1000,8 +1000,8 @@ func limit(r *http.Request, fallback, max int) int {
|
||||
return parsed
|
||||
}
|
||||
|
||||
func parseInt64(value string) int64 {
|
||||
parsed, _ := strconv.ParseInt(strings.TrimSpace(value), 10, 64)
|
||||
func parseUserIDQuery(value string) int64 {
|
||||
parsed, _ := parseUserID(value)
|
||||
return parsed
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user