mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-07 07:47:02 +02:00
Refactor webhook (#31587)
A more complete fix for #31588 1. Make "generic" code more readable 2. Clarify HTML or Markdown for the payload content
This commit is contained in:
1 parent
4ea2a6de81
commit
72b6bc8caf
18 files changed
+173
-182
No files matched your search
@@ -29,10 +29,10 @@ func newMatrixRequest(_ context.Context, w *webhook_model.Webhook, t *webhook_mo
|
||||
if err := json.Unmarshal([]byte(w.Meta), meta); err != nil {
|
||||
return nil, nil, fmt.Errorf("GetMatrixPayload meta json: %w", err)
|
||||
}
|
||||
mc := matrixConvertor{
|
||||
var pc payloadConvertor[MatrixPayload] = matrixConvertor{
|
||||
MsgType: messageTypeText[meta.MessageType],
|
||||
}
|
||||
payload, err := newPayload(mc, []byte(t.PayloadContent), t.EventType)
|
||||
payload, err := newPayload(pc, []byte(t.PayloadContent), t.EventType)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -87,8 +87,6 @@ type MatrixPayload struct {
|
||||
Commits []*api.PayloadCommit `json:"io.gitea.commits,omitempty"`
|
||||
}
|
||||
|
||||
var _ payloadConvertor[MatrixPayload] = matrixConvertor{}
|
||||
|
||||
type matrixConvertor struct {
|
||||
MsgType string
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user