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

wechat.go 1.1 kB

2 years ago
2 years ago
2 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2019 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 wechat
  5. import (
  6. "code.gitea.io/gitea/models"
  7. "code.gitea.io/gitea/modules/auth/wechat"
  8. "code.gitea.io/gitea/modules/notification/base"
  9. "code.gitea.io/gitea/modules/setting"
  10. )
  11. type wechatNotifier struct {
  12. base.NullNotifier
  13. }
  14. var (
  15. _ base.Notifier = &wechatNotifier{}
  16. )
  17. // NewNotifier create a new wechatNotifier notifier
  18. func NewNotifier() base.Notifier {
  19. return &wechatNotifier{}
  20. }
  21. func (*wechatNotifier) NotifyChangeCloudbrainStatus(cloudbrain *models.Cloudbrain, oldStatus string) {
  22. operateType := wechat.GetJobOperateTypeFromCloudbrainStatus(cloudbrain)
  23. if operateType == "" {
  24. return
  25. }
  26. switch operateType {
  27. case wechat.JobOperateTypeStart:
  28. if len(setting.CloudbrainStartedNotifyList) == 0 {
  29. return
  30. }
  31. for _, v := range setting.CloudbrainStartedNotifyList {
  32. if v == cloudbrain.JobType {
  33. go wechat.SendCloudbrainStartedMsg(operateType, *cloudbrain)
  34. return
  35. }
  36. }
  37. }
  38. }