Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/src/routes/bookings/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
const id = pendingCancelId;
if (!id) return;
try {
await api.post(`/v1/bookings/${id}/cancel`, { reason: 'cancelled by admin' });
await api.post(`/v1/bookings/${id}/cancel`, {});
await load();
} catch (e: any) {
error = e.message;
Expand Down
22 changes: 20 additions & 2 deletions internal/handler/booking_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -1625,13 +1625,31 @@ func (h *Handler) CancelBooking(w http.ResponseWriter, r *http.Request) {
// Ignore decode errors — reason is optional.
_ = json.NewDecoder(r.Body).Decode(&req)


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This blank line (and the one added at new line 1645) contains a literal tab. gofmt rewrites it and the repo's CI gofmt check step lists the file; the file is already flagged on main for other drift, so this is not blocking — but dropping the tab keeps these new lines clean.

actor := user.Name
if actor == "" {
actor = user.Email
}
if actor == "" {
actor = "host"
}

// Compose the attribution server-side.
// Ignore legacy hardcoded "cancelled by admin" from older frontend builds.
reason := fmt.Sprintf("Cancelled by %s", actor)
cleanReason := strings.TrimSpace(req.Reason)
if cleanReason != "" && !strings.EqualFold(cleanReason, "cancelled by admin") {
reason = fmt.Sprintf("%s: %s", reason, cleanReason)
}


// Admins (and the owner) may cancel any booking — needed to resolve a
// departing member's meetings. Non-admin hosts can cancel only their own.
var cancelErr error
if user.IsAdmin {
cancelErr = h.bookingSvc.CancelByID(r.Context(), id, req.Reason)
cancelErr = h.bookingSvc.CancelByID(r.Context(), id, reason)
} else {
cancelErr = h.bookingSvc.Cancel(r.Context(), user.ID, id, req.Reason)
cancelErr = h.bookingSvc.Cancel(r.Context(), user.ID, id, reason)
}
if err := cancelErr; err != nil {
switch {
Expand Down
Loading