Fix Matrix and MSTeams nil dereference (#28089) (#28105)

Backport #28089 by @KN4CK3R

Fixes #28088 
Fixes #28094

Added missing tests.

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
Giteabot 2023-11-17 21:50:45 +08:00 committed by GitHub
parent 56bedf2bcc
commit 1f82be6604
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 155 additions and 6 deletions

View file

@ -316,11 +316,12 @@ func GetMSTeamsPayload(p api.Payloader, event webhook_module.HookEventType, _ st
}
func createMSTeamsPayload(r *api.Repository, s *api.User, title, text, actionTarget string, color int, fact *MSTeamsFact) *MSTeamsPayload {
facts := []MSTeamsFact{
{
facts := make([]MSTeamsFact, 0, 2)
if r != nil {
facts = append(facts, MSTeamsFact{
Name: "Repository:",
Value: r.FullName,
},
})
}
if fact != nil {
facts = append(facts, *fact)