You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
726 B

  1. // Copyright 2020 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package migrations
  5. import (
  6. "code.gitea.io/gitea/modules/log"
  7. "xorm.io/builder"
  8. "xorm.io/xorm"
  9. )
  10. func updateMatrixWebhookHTTPMethod(x *xorm.Engine) error {
  11. var matrixHookTaskType = 9 // value comes from the models package
  12. type Webhook struct {
  13. HTTPMethod string
  14. }
  15. cond := builder.Eq{"hook_task_type": matrixHookTaskType}.And(builder.Neq{"http_method": "PUT"})
  16. count, err := x.Where(cond).Cols("http_method").Update(&Webhook{HTTPMethod: "PUT"})
  17. if err == nil {
  18. log.Debug("Updated %d Matrix webhooks with http_method 'PUT'", count)
  19. }
  20. return err
  21. }