diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2023-10-31 12:43:38 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-31 04:43:38 +0000 |
commit | 16d15ce087cd4b9ddf91f6acff7eacac24e6aac5 (patch) | |
tree | a71425c3ab1c5ee0c3ca6a8b8eaefd1367ecbfc8 /services/webhook/matrix.go | |
parent | 9106514e516f1e75ae539f3cd2f3a794c7d2c50a (diff) | |
download | gitea-16d15ce087cd4b9ddf91f6acff7eacac24e6aac5.tar.gz gitea-16d15ce087cd4b9ddf91f6acff7eacac24e6aac5.zip |
Fix package webhook (#27839)
Fix #23742
---------
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Diffstat (limited to 'services/webhook/matrix.go')
-rw-r--r-- | services/webhook/matrix.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/services/webhook/matrix.go b/services/webhook/matrix.go index a7f57f97b6..ab7e6b72c2 100644 --- a/services/webhook/matrix.go +++ b/services/webhook/matrix.go @@ -210,6 +210,21 @@ func (m *MatrixPayload) Repository(p *api.RepositoryPayload) (api.Payloader, err return getMatrixPayload(text, nil, m.MsgType), nil } +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) + var text string + + switch p.Action { + case api.HookPackageCreated: + text = fmt.Sprintf("[%s] Package published by %s", repoLink, senderLink) + case api.HookPackageDeleted: + text = fmt.Sprintf("[%s] Package deleted by %s", repoLink, senderLink) + } + + return getMatrixPayload(text, nil, m.MsgType), nil +} + // GetMatrixPayload converts a Matrix webhook into a MatrixPayload func GetMatrixPayload(p api.Payloader, event webhook_module.HookEventType, meta string) (api.Payloader, error) { s := new(MatrixPayload) |