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

3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536
  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/log"
  9. "code.gitea.io/gitea/modules/notification/base"
  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. log.Info("NotifyChangeCloudbrainStatus cloudbrain.id=%d cloudbrain.status=%s oldStatus=%s", cloudbrain.ID, cloudbrain.Status, oldStatus)
  23. operateType := wechat.GetJobOperateTypeFromCloudbrainStatus(cloudbrain)
  24. if operateType == "" {
  25. log.Info("NotifyChangeCloudbrainStatus operateType is incorrect")
  26. return
  27. }
  28. template := wechat.GetTemplateFromOperateType(operateType)
  29. go wechat.SendTemplateMsg(template, &wechat.TemplateContext{Cloudbrain: cloudbrain}, cloudbrain.UserID)
  30. }