feat(wxwork): remove unused recipient fields from wxWorkNotifyConfig
This commit is contained in:
@@ -88,10 +88,6 @@ wxWork:
|
|||||||
enabled: false
|
enabled: false
|
||||||
# 默认接收通知的成员ID列表;如业务目标用户已绑定企业微信身份,会优先发给目标用户。
|
# 默认接收通知的成员ID列表;如业务目标用户已绑定企业微信身份,会优先发给目标用户。
|
||||||
toUsers: []
|
toUsers: []
|
||||||
# 默认接收通知的部门ID列表。
|
|
||||||
toParties: []
|
|
||||||
# 默认接收通知的标签ID列表。
|
|
||||||
toTags: []
|
|
||||||
# 是否发送保密消息。
|
# 是否发送保密消息。
|
||||||
safe: false
|
safe: false
|
||||||
# 是否开启重复消息检查。
|
# 是否开启重复消息检查。
|
||||||
|
|||||||
@@ -22,8 +22,6 @@ type Config struct {
|
|||||||
type WxWorkNotifyConfig struct {
|
type WxWorkNotifyConfig struct {
|
||||||
Enabled bool `yaml:"enabled"`
|
Enabled bool `yaml:"enabled"`
|
||||||
ToUsers []string `yaml:"toUsers"`
|
ToUsers []string `yaml:"toUsers"`
|
||||||
ToParties []string `yaml:"toParties"`
|
|
||||||
ToTags []string `yaml:"toTags"`
|
|
||||||
Safe bool `yaml:"safe"`
|
Safe bool `yaml:"safe"`
|
||||||
EnableDuplicateCheck bool `yaml:"enableDuplicateCheck"`
|
EnableDuplicateCheck bool `yaml:"enableDuplicateCheck"`
|
||||||
DuplicateCheckInterval int `yaml:"duplicateCheckInterval"`
|
DuplicateCheckInterval int `yaml:"duplicateCheckInterval"`
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ type wxWorkMessageSender interface {
|
|||||||
|
|
||||||
type wxWorkNotifyRecipients struct {
|
type wxWorkNotifyRecipients struct {
|
||||||
ToUsers []string
|
ToUsers []string
|
||||||
ToParties []string
|
|
||||||
ToTags []string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type wxWorkNotifyService struct {
|
type wxWorkNotifyService struct {
|
||||||
@@ -79,8 +77,6 @@ func (s *wxWorkNotifyService) sendText(title, body string, recipients wxWorkNoti
|
|||||||
req := wxmessage.SendTextRequest{
|
req := wxmessage.SendTextRequest{
|
||||||
SendRequestCommon: &wxmessage.SendRequestCommon{
|
SendRequestCommon: &wxmessage.SendRequestCommon{
|
||||||
ToUser: strings.Join(recipients.ToUsers, "|"),
|
ToUser: strings.Join(recipients.ToUsers, "|"),
|
||||||
ToParty: strings.Join(recipients.ToParties, "|"),
|
|
||||||
ToTag: strings.Join(recipients.ToTags, "|"),
|
|
||||||
AgentID: strings.TrimSpace(cfg.AgentID),
|
AgentID: strings.TrimSpace(cfg.AgentID),
|
||||||
Safe: cast.ToInt(cfg.Notify.Safe),
|
Safe: cast.ToInt(cfg.Notify.Safe),
|
||||||
EnableDuplicateCheck: cast.ToInt(cfg.Notify.EnableDuplicateCheck),
|
EnableDuplicateCheck: cast.ToInt(cfg.Notify.EnableDuplicateCheck),
|
||||||
@@ -118,8 +114,6 @@ func (s *wxWorkNotifyService) defaultRecipients() wxWorkNotifyRecipients {
|
|||||||
cfg := config.Current().WxWork.Notify
|
cfg := config.Current().WxWork.Notify
|
||||||
return wxWorkNotifyRecipients{
|
return wxWorkNotifyRecipients{
|
||||||
ToUsers: arrs.Distinct(cfg.ToUsers),
|
ToUsers: arrs.Distinct(cfg.ToUsers),
|
||||||
ToParties: arrs.Distinct(cfg.ToParties),
|
|
||||||
ToTags: arrs.Distinct(cfg.ToTags),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,7 +143,7 @@ func (s *wxWorkNotifyService) normalizeDuplicateCheckInterval(value int) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r wxWorkNotifyRecipients) empty() bool {
|
func (r wxWorkNotifyRecipients) empty() bool {
|
||||||
return len(r.ToUsers) == 0 && len(r.ToParties) == 0 && len(r.ToTags) == 0
|
return len(r.ToUsers) == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func truncateRunes(value string, max int) string {
|
func truncateRunes(value string, max int) string {
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ func TestWxWorkNotifyDefaultRecipients(t *testing.T) {
|
|||||||
Notify: config.WxWorkNotifyConfig{
|
Notify: config.WxWorkNotifyConfig{
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
ToUsers: []string{" user_a ", "user_a", ""},
|
ToUsers: []string{" user_a ", "user_a", ""},
|
||||||
ToParties: []string{"2", "2"},
|
|
||||||
ToTags: []string{"tag-1"},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -31,12 +29,6 @@ func TestWxWorkNotifyDefaultRecipients(t *testing.T) {
|
|||||||
if len(recipients.ToUsers) != 1 || recipients.ToUsers[0] != "user_a" {
|
if len(recipients.ToUsers) != 1 || recipients.ToUsers[0] != "user_a" {
|
||||||
t.Fatalf("unexpected users: %#v", recipients.ToUsers)
|
t.Fatalf("unexpected users: %#v", recipients.ToUsers)
|
||||||
}
|
}
|
||||||
if len(recipients.ToParties) != 1 || recipients.ToParties[0] != "2" {
|
|
||||||
t.Fatalf("unexpected parties: %#v", recipients.ToParties)
|
|
||||||
}
|
|
||||||
if len(recipients.ToTags) != 1 || recipients.ToTags[0] != "tag-1" {
|
|
||||||
t.Fatalf("unexpected tags: %#v", recipients.ToTags)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWxWorkNotifyNormalizeDuplicateCheckInterval(t *testing.T) {
|
func TestWxWorkNotifyNormalizeDuplicateCheckInterval(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user