mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-11-03 20:36:07 +01:00 
			
		
		
		
	Fix Matrix and MSTeams nil dereference (#28089)
Fixes #28088 Fixes #28094 Added missing tests. --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
		@@ -212,14 +212,14 @@ func (m *MatrixPayload) Repository(p *api.RepositoryPayload) (api.Payloader, err
 | 
			
		||||
 | 
			
		||||
func (m *MatrixPayload) Package(p *api.PackagePayload) (api.Payloader, error) {
 | 
			
		||||
	senderLink := MatrixLinkFormatter(setting.AppURL+p.Sender.UserName, p.Sender.UserName)
 | 
			
		||||
	repoLink := MatrixLinkFormatter(p.Repository.HTMLURL, p.Repository.FullName)
 | 
			
		||||
	packageLink := MatrixLinkFormatter(p.Package.HTMLURL, p.Package.Name)
 | 
			
		||||
	var text string
 | 
			
		||||
 | 
			
		||||
	switch p.Action {
 | 
			
		||||
	case api.HookPackageCreated:
 | 
			
		||||
		text = fmt.Sprintf("[%s] Package published by %s", repoLink, senderLink)
 | 
			
		||||
		text = fmt.Sprintf("[%s] Package published by %s", packageLink, senderLink)
 | 
			
		||||
	case api.HookPackageDeleted:
 | 
			
		||||
		text = fmt.Sprintf("[%s] Package deleted by %s", repoLink, senderLink)
 | 
			
		||||
		text = fmt.Sprintf("[%s] Package deleted by %s", packageLink, senderLink)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return getMatrixPayload(text, nil, m.MsgType), nil
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user