|
1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- // Copyright 2019 The Gitea Authors. All rights reserved.
- // Use of this source code is governed by a MIT-style
- // license that can be found in the LICENSE file.
-
- package wechat
-
- import (
- "code.gitea.io/gitea/models"
- "code.gitea.io/gitea/modules/auth/wechat"
- "code.gitea.io/gitea/modules/notification/base"
- "code.gitea.io/gitea/modules/setting"
- )
-
- type wechatNotifier struct {
- base.NullNotifier
- }
-
- var (
- _ base.Notifier = &wechatNotifier{}
- )
-
- // NewNotifier create a new wechatNotifier notifier
- func NewNotifier() base.Notifier {
- return &wechatNotifier{}
- }
-
- func (*wechatNotifier) NotifyChangeCloudbrainStatus(cloudbrain *models.Cloudbrain, oldStatus string) {
- operateType := wechat.GetJobOperateTypeFromCloudbrainStatus(cloudbrain)
- if operateType == "" {
- return
- }
- switch operateType {
- case wechat.JobOperateTypeStart:
- if len(setting.CloudbrainStartedNotifyList) == 0 {
- return
- }
- for _, v := range setting.CloudbrainStartedNotifyList {
- if v == cloudbrain.JobType {
- go wechat.SendCloudbrainStartedMsg(operateType, *cloudbrain)
- return
- }
- }
- }
- }
|