-
Notifications
You must be signed in to change notification settings - Fork 182
/
noticeReceivers.go
56 lines (47 loc) · 1.42 KB
/
noticeReceivers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package settings
import (
"github.com/TeaWeb/build/internal/teaconfigs/agents"
"github.com/TeaWeb/build/internal/teaconfigs/notices"
"github.com/TeaWeb/build/internal/teaweb/actions/default/agents/agentutils"
"github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/lists"
"github.com/iwind/TeaGo/maps"
)
type NoticeReceiversAction actions.Action
// 通知接收人设置
func (this *NoticeReceiversAction) Run(params struct {
AgentId string
}) {
this.Data["selectedTab"] = "noticeSetting"
agent := agents.NewAgentConfigFromId(params.AgentId)
if agent == nil {
this.Fail("找不到Agent")
}
this.Data["agent"] = agent
group := agent.FirstGroup()
this.Data["groupId"] = group.Id
this.Data["levels"] = lists.Map(notices.AllNoticeLevels(), func(k int, v interface{}) interface{} {
level := v.(maps.Map)
code := level["code"].(notices.NoticeLevel)
receivers, found := agent.NoticeSetting[code]
// 当前Agent的设置
if found && len(receivers) > 0 {
level["receivers"] = agentutils.ConvertReceiversToMaps(receivers)
} else {
level["receivers"] = []interface{}{}
}
// 当前所属分组的设置
if group != nil {
groupReceivers, ok := group.NoticeSetting[code]
if ok {
level["groupReceivers"] = agentutils.ConvertReceiversToMaps(groupReceivers)
} else {
level["groupReceivers"] = []interface{}{}
}
} else {
level["groupReceivers"] = []interface{}{}
}
return level
})
this.Show()
}