gitea源码

1234567891011121314151617181920212223242526
  1. // Copyright 2020 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package v1_13
  4. import (
  5. "code.gitea.io/gitea/modules/log"
  6. "xorm.io/builder"
  7. "xorm.io/xorm"
  8. )
  9. func UpdateMatrixWebhookHTTPMethod(x *xorm.Engine) error {
  10. matrixHookTaskType := 9 // value comes from the models package
  11. type Webhook struct {
  12. HTTPMethod string
  13. }
  14. cond := builder.Eq{"hook_task_type": matrixHookTaskType}.And(builder.Neq{"http_method": "PUT"})
  15. count, err := x.Where(cond).Cols("http_method").Update(&Webhook{HTTPMethod: "PUT"})
  16. if err == nil {
  17. log.Debug("Updated %d Matrix webhooks with http_method 'PUT'", count)
  18. }
  19. return err
  20. }