SimpleCloudNotifier/scnserver/push/testSink.go
Mike Schwörer e329e13a02
All checks were successful
Build Docker and Deploy / Build Docker Container (push) Successful in 1m53s
Build Docker and Deploy / Deploy to Server (push) Successful in 7s
Auto-delete clients when FB returns UNREGISTERED
2024-09-16 20:11:28 +02:00

42 lines
773 B
Go

package push
import (
"blackforestbytes.com/simplecloudnotifier/models"
"context"
_ "embed"
"gogs.mikescher.com/BlackForestBytes/goext/langext"
)
type SinkData struct {
Message models.Message
Client models.Client
}
type TestSink struct {
Data []SinkData
}
func NewTestSink() NotificationClient {
return &TestSink{}
}
func (d *TestSink) Last() SinkData {
return d.Data[len(d.Data)-1]
}
func (d *TestSink) SendNotification(ctx context.Context, user models.User, client models.Client, channel models.Channel, msg models.Message) (string, string, error) {
id, err := langext.NewHexUUID()
if err != nil {
return "", "", err
}
key := "TestSink[" + id + "]"
d.Data = append(d.Data, SinkData{
Message: msg,
Client: client,
})
return key, "", nil
}