adjust sse notification layout

Signed-off-by: jkoberg <jkoberg@owncloud.com>
This commit is contained in:
jkoberg
2023-10-10 10:22:23 +02:00
parent efafb64cab
commit 25e7b1aaaa

View File

@@ -1,7 +1,6 @@
package service
import (
"encoding/json"
"net/http"
revactx "github.com/cs3org/reva/v2/pkg/ctx"
@@ -13,12 +12,6 @@ import (
"github.com/owncloud/ocis/v2/services/sse/pkg/config"
)
// ServerSentEvent is the data structure sent by the sse service
type ServerSentEvent struct {
Type string `json:"type"`
Data json.RawMessage `json:"data"`
}
// SSE defines implements the business logic for Service.
type SSE struct {
c *config.Config
@@ -58,16 +51,9 @@ func (s SSE) ListenForEvents() {
default:
s.l.Error().Interface("event", ev).Msg("unhandled event")
case events.SendSSE:
b, err := json.Marshal(ServerSentEvent{
Type: ev.Type,
Data: ev.Message,
})
if err != nil {
s.l.Error().Interface("event", ev).Msg("cannot marshal event")
continue
}
s.sse.Publish(ev.UserID, &sse.Event{
Data: b,
Event: []byte(ev.Type),
Data: ev.Message,
})
}
}