Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions app/models/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package models
import (
"database/sql/driver"
"errors"
"strconv"

"github.com/goravel/framework/contracts/notification"
"github.com/goravel/framework/database/orm"
"github.com/goravel/framework/support/json"
)
Expand Down Expand Up @@ -40,14 +42,21 @@ func (r *UserTag) Value() (driver.Value, error) {
return json.Marshal(r)
}

// RouteNotificationFor resolves the delivery address per channel.
// RouteNotificationForMail implements contracts/notification.MailRoutable:
// the type-safe mail delivery route, preferred over RouteNotificationFor.
func (r *User) RouteNotificationForMail(notification notification.Notification) map[string]string {
return map[string]string{r.Mail: r.Name}
}

// RouteNotificationForDatabase implements contracts/notification.DatabaseRoutable:
// the type-safe database delivery route, preferred over RouteNotificationFor.
func (r *User) RouteNotificationForDatabase() string {
return strconv.FormatUint(uint64(r.ID), 10)
}

// RouteNotificationFor resolves the delivery address per channel. The built-in
// mail and database channels resolve via the typed interfaces above, so no
// route is left to match on the channel name here.
func (r *User) RouteNotificationFor(channel string) any {
switch channel {
case "mail":
return r.Mail
case "database":
return r.ID
default:
return nil
}
return nil
}
2 changes: 1 addition & 1 deletion app/notifications/order_processed.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func NewOrderProcessed(orderID string) *OrderProcessed {
}

func (r *OrderProcessed) Via(notifiable notification.Notifiable) []string {
return []string{"database"}
return []string{notification.ChannelDatabase}
}

func (r *OrderProcessed) ToDatabase(notifiable notification.Notifiable) map[string]any {
Expand Down
2 changes: 1 addition & 1 deletion app/notifications/order_shipped.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func NewOrderShipped(orderID string) *OrderShipped {
}

func (r *OrderShipped) Via(notifiable notification.Notifiable) []string {
return []string{"mail"}
return []string{notification.ChannelMail}
}

func (r *OrderShipped) ToMail(notifiable notification.Notifiable) notification.MailMessage {
Expand Down
2 changes: 1 addition & 1 deletion app/notifications/welcome.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func NewWelcome(name string) *Welcome {
}

func (r *Welcome) Via(notifiable notification.Notifiable) []string {
return []string{"database"}
return []string{notification.ChannelDatabase}
}

func (r *Welcome) ID() string {
Expand Down
58 changes: 29 additions & 29 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/goravel/cos v1.18.0
github.com/goravel/example-proto v0.0.1
github.com/goravel/fiber v1.18.0
github.com/goravel/framework v1.18.1-0.20260805080351-d2e95f66f306
github.com/goravel/framework v1.18.1-0.20260816093758-fcfadc23b062
github.com/goravel/gemini v1.18.0
github.com/goravel/gin v1.18.0
github.com/goravel/minio v1.18.0
Expand All @@ -29,11 +29,11 @@ require (
github.com/swaggo/swag v1.16.2
github.com/uber/jaeger-client-go v2.30.0+incompatible
github.com/vektah/gqlparser/v2 v2.5.19
go.opentelemetry.io/otel v1.44.0
go.opentelemetry.io/otel/metric v1.44.0
go.opentelemetry.io/otel/trace v1.44.0
go.opentelemetry.io/otel v1.45.0
go.opentelemetry.io/otel/metric v1.45.0
go.opentelemetry.io/otel/trace v1.45.0
google.golang.org/grpc v1.83.0
google.golang.org/protobuf v1.36.11
google.golang.org/protobuf v1.36.12
)

require (
Expand Down Expand Up @@ -94,13 +94,13 @@ require (
github.com/dromara/carbon/v2 v2.6.11 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/felixge/httpsnoop v1.1.0 // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.15 // indirect
github.com/gin-contrib/sse v1.1.0 // indirect
github.com/gin-contrib/timeout v1.2.1 // indirect
github.com/gin-gonic/gin v1.12.0 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/logr v1.4.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.20.2 // indirect
github.com/go-openapi/jsonreference v0.20.4 // indirect
Expand Down Expand Up @@ -213,29 +213,29 @@ require (
github.com/zeebo/xxh3 v1.1.0 // indirect
go.mongodb.org/mongo-driver/v2 v2.5.0 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.69.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.69.0 // indirect
go.opentelemetry.io/contrib/propagators/b3 v1.44.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.20.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.20.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.44.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.44.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.44.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.44.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.44.0 // indirect
go.opentelemetry.io/otel/exporters/stdout/stdoutlog v0.20.0 // indirect
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.44.0 // indirect
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.44.0 // indirect
go.opentelemetry.io/otel/log v0.20.0 // indirect
go.opentelemetry.io/otel/sdk v1.44.0 // indirect
go.opentelemetry.io/otel/sdk/log v0.20.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.44.0 // indirect
go.opentelemetry.io/proto/otlp v1.10.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.70.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.70.0 // indirect
go.opentelemetry.io/contrib/propagators/b3 v1.45.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.21.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.21.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.45.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.45.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.45.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.45.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.45.0 // indirect
go.opentelemetry.io/otel/exporters/stdout/stdoutlog v0.21.0 // indirect
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.45.0 // indirect
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.45.0 // indirect
go.opentelemetry.io/otel/log v0.21.0 // indirect
go.opentelemetry.io/otel/sdk v1.45.0 // indirect
go.opentelemetry.io/otel/sdk/log v0.21.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.45.0 // indirect
go.opentelemetry.io/proto/otlp v1.11.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/arch v0.22.0 // indirect
golang.org/x/crypto v0.54.0 // indirect
golang.org/x/exp v0.0.0-20260727155853-b88d891fe743 // indirect
golang.org/x/exp v0.0.0-20260810151157-a8b543ca52da // indirect
golang.org/x/mod v0.38.0 // indirect
golang.org/x/net v0.57.0 // indirect
golang.org/x/sync v0.22.0 // indirect
Expand All @@ -245,8 +245,8 @@ require (
golang.org/x/time v0.14.0 // indirect
golang.org/x/tools v0.48.0 // indirect
google.golang.org/genai v1.58.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20260526163538-3dc84a4a5aaa // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260526163538-3dc84a4a5aaa // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20260803160001-6ac0973c030d // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260803160001-6ac0973c030d // indirect
gopkg.in/ini.v1 v1.67.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gorm.io/driver/mysql v1.6.0 // indirect
Expand All @@ -256,4 +256,4 @@ require (
gorm.io/plugin/dbresolver v1.6.2 // indirect
)

replace github.com/goravel/framework => github.com/goravel/framework v1.18.1-0.20260805080351-d2e95f66f306
replace github.com/goravel/framework => github.com/goravel/framework v1.18.1-0.20260816093758-fcfadc23b062
Loading
Loading