2022-11-23 20:21:49 +01:00
|
|
|
package push
|
|
|
|
|
|
|
|
import (
|
|
|
|
"blackforestbytes.com/simplecloudnotifier/models"
|
|
|
|
"context"
|
|
|
|
_ "embed"
|
|
|
|
"gogs.mikescher.com/BlackForestBytes/goext/langext"
|
|
|
|
)
|
|
|
|
|
|
|
|
type SinkData struct {
|
2024-06-01 15:37:59 +02:00
|
|
|
Message models.Message
|
|
|
|
Client models.Client
|
2022-11-23 20:21:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type TestSink struct {
|
2022-11-30 17:58:04 +01:00
|
|
|
Data []SinkData
|
2022-11-23 20:21:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewTestSink() NotificationClient {
|
|
|
|
return &TestSink{}
|
|
|
|
}
|
|
|
|
|
2022-11-30 17:58:04 +01:00
|
|
|
func (d *TestSink) Last() SinkData {
|
|
|
|
return d.Data[len(d.Data)-1]
|
|
|
|
}
|
|
|
|
|
2024-09-16 20:11:28 +02:00
|
|
|
func (d *TestSink) SendNotification(ctx context.Context, user models.User, client models.Client, channel models.Channel, msg models.Message) (string, string, error) {
|
2022-11-23 20:21:49 +01:00
|
|
|
id, err := langext.NewHexUUID()
|
|
|
|
if err != nil {
|
2024-09-16 20:11:28 +02:00
|
|
|
return "", "", err
|
2022-11-23 20:21:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
key := "TestSink[" + id + "]"
|
|
|
|
|
2022-11-30 17:58:04 +01:00
|
|
|
d.Data = append(d.Data, SinkData{
|
2024-06-01 15:37:59 +02:00
|
|
|
Message: msg,
|
|
|
|
Client: client,
|
2022-11-23 20:21:49 +01:00
|
|
|
})
|
|
|
|
|
2024-09-16 20:11:28 +02:00
|
|
|
return key, "", nil
|
2022-11-23 20:21:49 +01:00
|
|
|
}
|