Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Merge Actions: cross-repo workflows and actions, release and deployment triggers, step timeouts | 1 | import type { Comment } from "@g1t/contracts"; |
| 2 | ||
| 3 | /** | |
| 4 | * Whether the viewer may edit or delete a comment: its author may, and so | |
| 5 | * may someone with the Maintain role or higher (`canModerate`). Notes of | |
| 6 | * what happened are nobody's to change, and a review's verdict stays, so a | |
| 7 | * review can be edited but not deleted. The work service decides; this | |
| 8 | * only says which buttons to show. | |
| 9 | */ | |
| 10 | export function mayChangeComment( | |
| 11 | comment: Pick<Comment, "kind" | "verdict"> & { author: { id: string } }, | |
| 12 | viewerId: string | null | undefined, | |
| 13 | canModerate: boolean, | |
| 14 | ): { edit: boolean; delete: boolean } { | |
| 15 | const allowed = comment.kind === "comment" && viewerId != null && (comment.author.id === viewerId || canModerate); | |
| 16 | return { edit: allowed, delete: allowed && comment.verdict == null }; | |
| 17 | } |
This file's history is long; its oldest lines are credited to the oldest commit read.