Skip to content
Merged
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
15 changes: 7 additions & 8 deletions cmd/comment/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func newDeleteCmd(f *factory.Factory) *cobra.Command {
cmd := &cobra.Command{
Use: "delete <comment-id|url>",
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
Expand Down Expand Up @@ -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 {
Expand All @@ -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
Expand Down
11 changes: 11 additions & 0 deletions internal/api/comments.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
1 change: 1 addition & 0 deletions internal/api/modular.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading