diff --git a/cmd/comment/delete.go b/cmd/comment/delete.go index 24bb34a..e882cab 100644 --- a/cmd/comment/delete.go +++ b/cmd/comment/delete.go @@ -20,7 +20,7 @@ func newDeleteCmd(f *factory.Factory) *cobra.Command { cmd := &cobra.Command{ Use: "delete ", Short: "Delete a comment", - Long: `Delete a comment. This operation cannot be undone.`, + Long: `Trash a comment on a recording. Trashed comments can be recovered from the Basecamp trash.`, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { // Apply overrides if specified @@ -73,9 +73,9 @@ func newDeleteCmd(f *factory.Factory) *cobra.Command { if !skipConfirm { var confirm bool if err := huh.NewConfirm(). - Title(fmt.Sprintf("Delete comment #%d?", commentID)). + Title(fmt.Sprintf("Trash comment #%d?", commentID)). Description(fmt.Sprintf("By %s on %s", comment.Creator.Name, comment.CreatedAt.Format("Jan 2, 2006"))). - Affirmative("Delete"). + Affirmative("Trash"). Negative("Cancel"). Value(&confirm). Run(); err != nil { @@ -88,15 +88,14 @@ func newDeleteCmd(f *factory.Factory) *cobra.Command { } } - // Delete the comment - path := fmt.Sprintf("/buckets/%s/comments/%d.json", projectID, commentID) - if err := client.Delete(path); err != nil { - return fmt.Errorf("failed to delete comment: %w", err) + // Trash the comment via Basecamp recordings API + if err := client.TrashComment(f.Context(), projectID, commentID); err != nil { + return err } // Output if ui.IsTerminal(os.Stdout) { - fmt.Printf("✓ Deleted comment #%d\n", commentID) + fmt.Printf("✓ Trashed comment #%d\n", commentID) } return nil diff --git a/internal/api/comments.go b/internal/api/comments.go index 86541ba..57f89c0 100644 --- a/internal/api/comments.go +++ b/internal/api/comments.go @@ -82,3 +82,14 @@ func (c *Client) UpdateComment(ctx context.Context, projectID string, commentID return &comment, nil } + +// TrashComment trashes a comment via the recordings status endpoint +func (c *Client) TrashComment(ctx context.Context, projectID string, commentID int64) error { + path := fmt.Sprintf("/buckets/%s/recordings/%d/status/trashed.json", projectID, commentID) + + if err := c.Put(path, nil, nil); err != nil { + return fmt.Errorf("failed to trash comment: %w", err) + } + + return nil +} diff --git a/internal/api/modular.go b/internal/api/modular.go index 623729e..b72dd10 100644 --- a/internal/api/modular.go +++ b/internal/api/modular.go @@ -106,6 +106,7 @@ type CommentOperations interface { GetComment(ctx context.Context, projectID string, commentID int64) (*Comment, error) CreateComment(ctx context.Context, projectID string, recordingID int64, req CommentCreateRequest) (*Comment, error) UpdateComment(ctx context.Context, projectID string, commentID int64, req CommentUpdateRequest) (*Comment, error) + TrashComment(ctx context.Context, projectID string, commentID int64) error } // ActivityOperations defines activity-specific operations