From 8c31a9c444948e96506a51794e519459adcc0815 Mon Sep 17 00:00:00 2001 From: mlogclub Date: Tue, 21 Apr 2026 17:36:05 +0800 Subject: [PATCH] feat(wxwork): remove unused recipient fields from wxWorkNotifyConfig --- config/config.example.yaml | 4 ---- internal/pkg/config/config.go | 2 -- internal/services/wxwork_notify_service.go | 12 +++--------- internal/services/wxwork_notify_service_test.go | 12 ++---------- 4 files changed, 5 insertions(+), 25 deletions(-) diff --git a/config/config.example.yaml b/config/config.example.yaml index b538399..15a7b62 100644 --- a/config/config.example.yaml +++ b/config/config.example.yaml @@ -88,10 +88,6 @@ wxWork: enabled: false # 默认接收通知的成员ID列表;如业务目标用户已绑定企业微信身份,会优先发给目标用户。 toUsers: [] - # 默认接收通知的部门ID列表。 - toParties: [] - # 默认接收通知的标签ID列表。 - toTags: [] # 是否发送保密消息。 safe: false # 是否开启重复消息检查。 diff --git a/internal/pkg/config/config.go b/internal/pkg/config/config.go index b2b2a7e..9e29364 100644 --- a/internal/pkg/config/config.go +++ b/internal/pkg/config/config.go @@ -22,8 +22,6 @@ type Config struct { type WxWorkNotifyConfig struct { Enabled bool `yaml:"enabled"` ToUsers []string `yaml:"toUsers"` - ToParties []string `yaml:"toParties"` - ToTags []string `yaml:"toTags"` Safe bool `yaml:"safe"` EnableDuplicateCheck bool `yaml:"enableDuplicateCheck"` DuplicateCheckInterval int `yaml:"duplicateCheckInterval"` diff --git a/internal/services/wxwork_notify_service.go b/internal/services/wxwork_notify_service.go index 9431582..85788a4 100644 --- a/internal/services/wxwork_notify_service.go +++ b/internal/services/wxwork_notify_service.go @@ -22,9 +22,7 @@ type wxWorkMessageSender interface { } type wxWorkNotifyRecipients struct { - ToUsers []string - ToParties []string - ToTags []string + ToUsers []string } type wxWorkNotifyService struct { @@ -79,8 +77,6 @@ func (s *wxWorkNotifyService) sendText(title, body string, recipients wxWorkNoti req := wxmessage.SendTextRequest{ SendRequestCommon: &wxmessage.SendRequestCommon{ ToUser: strings.Join(recipients.ToUsers, "|"), - ToParty: strings.Join(recipients.ToParties, "|"), - ToTag: strings.Join(recipients.ToTags, "|"), AgentID: strings.TrimSpace(cfg.AgentID), Safe: cast.ToInt(cfg.Notify.Safe), EnableDuplicateCheck: cast.ToInt(cfg.Notify.EnableDuplicateCheck), @@ -117,9 +113,7 @@ func (s *wxWorkNotifyService) resolveRecipientsByUserIDs(userIDs []int64) wxWork func (s *wxWorkNotifyService) defaultRecipients() wxWorkNotifyRecipients { cfg := config.Current().WxWork.Notify return wxWorkNotifyRecipients{ - ToUsers: arrs.Distinct(cfg.ToUsers), - ToParties: arrs.Distinct(cfg.ToParties), - ToTags: arrs.Distinct(cfg.ToTags), + ToUsers: arrs.Distinct(cfg.ToUsers), } } @@ -149,7 +143,7 @@ func (s *wxWorkNotifyService) normalizeDuplicateCheckInterval(value int) int { } 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 { diff --git a/internal/services/wxwork_notify_service_test.go b/internal/services/wxwork_notify_service_test.go index 978cb64..96ab484 100644 --- a/internal/services/wxwork_notify_service_test.go +++ b/internal/services/wxwork_notify_service_test.go @@ -18,10 +18,8 @@ func TestWxWorkNotifyDefaultRecipients(t *testing.T) { config.SetCurrent(&config.Config{ WxWork: config.WxWorkConfig{ Notify: config.WxWorkNotifyConfig{ - Enabled: true, - ToUsers: []string{" user_a ", "user_a", ""}, - ToParties: []string{"2", "2"}, - ToTags: []string{"tag-1"}, + Enabled: true, + ToUsers: []string{" user_a ", "user_a", ""}, }, }, }) @@ -31,12 +29,6 @@ func TestWxWorkNotifyDefaultRecipients(t *testing.T) { if len(recipients.ToUsers) != 1 || recipients.ToUsers[0] != "user_a" { 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) {