mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-05 15:26:36 +08:00
refactor(mail): modernize smtp sending with go-mail and unify message gateway pusher
This commit is contained in:
@@ -6,6 +6,7 @@ package contracts
|
||||
|
||||
import "context"
|
||||
|
||||
// PushNotificationTemplate defines notification message template payload.
|
||||
type PushNotificationTemplate struct {
|
||||
Title string
|
||||
Content string
|
||||
@@ -13,6 +14,7 @@ type PushNotificationTemplate struct {
|
||||
Ext map[string]any
|
||||
}
|
||||
|
||||
// PushEventMeta defines metadata for a system push event.
|
||||
type PushEventMeta struct {
|
||||
Key string
|
||||
Name string
|
||||
@@ -20,6 +22,7 @@ type PushEventMeta struct {
|
||||
DefaultTemplate PushNotificationTemplate
|
||||
}
|
||||
|
||||
// PushRegistry defines the interface for registering built-in events.
|
||||
type PushRegistry interface {
|
||||
RegisterBuiltInEvent(meta PushEventMeta)
|
||||
SyncEvents(ctx context.Context) error
|
||||
|
||||
@@ -181,7 +181,7 @@ func formatEntryValue(value any, secret bool) string {
|
||||
return ""
|
||||
}
|
||||
rv := reflect.ValueOf(value)
|
||||
if rv.Kind() == reflect.Ptr {
|
||||
if rv.Kind() == reflect.Pointer {
|
||||
if rv.IsNil() {
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ func convertValue(raw any, typ reflect.Type) (any, error) {
|
||||
return convertSlice(raw, typ)
|
||||
case reflect.Struct:
|
||||
return convertStruct(raw, typ)
|
||||
case reflect.Ptr:
|
||||
case reflect.Pointer:
|
||||
return convertPointer(raw, typ)
|
||||
default:
|
||||
return nil, fmt.Errorf("%w: %s is not a supported configuration type", ErrConfigType, typ)
|
||||
@@ -44,7 +44,7 @@ func convertValue(raw any, typ reflect.Type) (any, error) {
|
||||
// Nested pointers are rejected so configuration tags stay one level deep.
|
||||
func convertPointer(raw any, typ reflect.Type) (any, error) {
|
||||
elemType := typ.Elem()
|
||||
if elemType.Kind() == reflect.Ptr {
|
||||
if elemType.Kind() == reflect.Pointer {
|
||||
return nil, fmt.Errorf("%w: %s is not a supported configuration type", ErrConfigType, typ)
|
||||
}
|
||||
elem, err := convertValue(raw, elemType)
|
||||
|
||||
Reference in New Issue
Block a user