Files
multica/server/pkg/db/generated/comment_row.go
Bohan Jiang a9e82c7973 MUL-7282: fix(comments): delete only the selected comment and keep its replies (#8323)
Deleting a comment removed every reply under it, through the parent_id ON DELETE CASCADE. Now delete removes only that comment: one with replies becomes a tombstone (deleted_at set, body/attachments/reactions/resolution cleared) so the replies keep their parent, and one without replies is removed along with any tombstone ancestor left empty.

Tombstones are read-only and are never agent input. Every write to a comment's children takes its owners first (issue -> comment -> child), and a comment commits together with the attachments it was posted with. Clients only promise that replies are kept when the server declares comment_delete_keep_replies_supported, and then delete through DELETE /api/comments/{id}/keep-replies, which older servers do not route.
2026-09-13 19:13:43 +08:00

54 lines
1.7 KiB
Go

package db
// Comment converts the sqlc row returned by the CTE-backed create query into
// the canonical model used by comment rendering and task side effects. The
// row's IssueRevision remains available separately for owner-cache coherence.
func (r CreateCommentRow) Comment() Comment {
return Comment{
ID: r.ID,
IssueID: r.IssueID,
AuthorType: r.AuthorType,
AuthorID: r.AuthorID,
Content: r.Content,
Type: r.Type,
CreatedAt: r.CreatedAt,
UpdatedAt: r.UpdatedAt,
ParentID: r.ParentID,
WorkspaceID: r.WorkspaceID,
ResolvedAt: r.ResolvedAt,
ResolvedByType: r.ResolvedByType,
ResolvedByID: r.ResolvedByID,
SourceTaskID: r.SourceTaskID,
QuickActionID: r.QuickActionID,
ViaPluginID: r.ViaPluginID,
Revision: r.Revision,
DeletedAt: r.DeletedAt,
}
}
// Comment converts the sqlc row returned by the CTE-backed update query into
// the canonical model. IssueRevision is aggregate-owner metadata and remains
// available on the row for response/event cache reconciliation.
func (r UpdateCommentRow) Comment() Comment {
return Comment{
ID: r.ID,
IssueID: r.IssueID,
AuthorType: r.AuthorType,
AuthorID: r.AuthorID,
Content: r.Content,
Type: r.Type,
CreatedAt: r.CreatedAt,
UpdatedAt: r.UpdatedAt,
ParentID: r.ParentID,
WorkspaceID: r.WorkspaceID,
ResolvedAt: r.ResolvedAt,
ResolvedByType: r.ResolvedByType,
ResolvedByID: r.ResolvedByID,
SourceTaskID: r.SourceTaskID,
QuickActionID: r.QuickActionID,
ViaPluginID: r.ViaPluginID,
Revision: r.Revision,
DeletedAt: r.DeletedAt,
}
}