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 905 B

3 years ago
123456789101112131415161718192021222324252627282930313233
  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. )
  10. type wechatNotifier struct {
  11. base.NullNotifier
  12. }
  13. var (
  14. _ base.Notifier = &wechatNotifier{}
  15. )
  16. // NewNotifier create a new wechatNotifier notifier
  17. func NewNotifier() base.Notifier {
  18. return &wechatNotifier{}
  19. }
  20. func (*wechatNotifier) NotifyChangeCloudbrainStatus(cloudbrain *models.Cloudbrain, oldStatus string) {
  21. operateType := wechat.GetJobOperateTypeFromCloudbrainStatus(cloudbrain)
  22. if operateType == "" {
  23. return
  24. }
  25. template := wechat.GetTemplateFromOperateType(operateType)
  26. go wechat.SendTemplateMsg(template, &wechat.TemplateContext{Cloudbrain: cloudbrain}, cloudbrain.UserID)
  27. }