mirror of
https://github.com/usual2970/certimate.git
synced 2025-10-05 22:14:53 +00:00
refactor: clean code
This commit is contained in:
@@ -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"`
|
||||
}
|
Reference in New Issue
Block a user