refactor: clean code

This commit is contained in:
Fu Diwei
2024-12-28 16:26:01 +08:00
parent 86133ba52b
commit 416f5e0986
12 changed files with 55 additions and 49 deletions

View File

@@ -11,10 +11,24 @@ type Settings struct {
Content string `json:"content" db:"content"`
}
type NotifyChannelsConfig map[string]map[string]any
type NotifyTemplatesSettingsContent struct {
NotifyTemplates []NotifyTemplate `json:"notifyTemplates"`
}
func (s *Settings) GetChannelContent(channel string) (map[string]any, error) {
conf := &NotifyChannelsConfig{}
type NotifyTemplate struct {
Subject string `json:"subject"`
Message string `json:"message"`
}
type NotifyChannelsSettingsContent map[string]map[string]any
type NotifyMessage struct {
Subject string `json:"subject"`
Message string `json:"message"`
}
func (s *Settings) GetNotifyChannelConfig(channel string) (map[string]any, error) {
conf := &NotifyChannelsSettingsContent{}
if err := json.Unmarshal([]byte(s.Content), conf); err != nil {
return nil, err
}
@@ -26,17 +40,3 @@ func (s *Settings) GetChannelContent(channel string) (map[string]any, error) {
return v, nil
}
type NotifyTemplates struct {
NotifyTemplates []NotifyTemplate `json:"notifyTemplates"`
}
type NotifyTemplate struct {
Subject string `json:"subject"`
Message string `json:"message"`
}
type NotifyMessage struct {
Subject string `json:"subject"`
Message string `json:"message"`
}