fix: aggregate deleted team as ghost team (#7987)

- If a review was requested from a deleted team, use the ghost team for the comment aggregator.
- Resolves Codeberg/Community#1952
- Unit test added.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7987
Reviewed-by: Beowulf <beowulf@beocode.eu>
Co-authored-by: Gusted <postmaster@gusted.xyz>
Co-committed-by: Gusted <postmaster@gusted.xyz>
This commit is contained in:
Gusted 2025-05-29 17:45:18 +02:00 committed by Gusted
parent 99d697263f
commit d6ab2a464f
3 changed files with 42 additions and 2 deletions

View file

@ -94,6 +94,14 @@ func reqReview(t int64, name string, delReq bool) *issue_model.Comment {
return c
}
func ghostReqReview(t, id int64) *issue_model.Comment {
c := testComment(t)
c.Type = issue_model.CommentTypeReviewRequest
c.AssigneeTeam = organization.NewGhostTeam()
c.AssigneeTeamID = id
return c
}
func reqReviewList(t int64, del bool, names ...string) *issue_model.Comment {
req := []issue_model.RequestReviewTarget{}
for _, name := range names {
@ -588,6 +596,27 @@ func TestCombineReviewRequests(t *testing.T) {
reqReviewList(121, true, "titi", "toto-team"),
},
},
// Ghost.
{
name: "ghost reviews",
beforeCombined: []*issue_model.Comment{
reqReview(1, "titi", false),
ghostReqReview(2, 50),
ghostReqReview(3, 51),
ghostReqReview(4, 50),
},
afterCombined: []*issue_model.Comment{
{
PosterID: 1,
Type: issue_model.CommentTypeReviewRequest,
CreatedUnix: timeutil.TimeStamp(1),
AddedRequestReview: []issue_model.RequestReviewTarget{
createReqReviewTarget("titi"), {Team: organization.NewGhostTeam()},
},
},
},
},
}
for _, kase := range kases {