More data on subscriptions
This commit is contained in:
@@ -2,6 +2,7 @@ package handlers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.coopgo.io/coopgo-platform/agenda/storage"
|
||||
"github.com/google/uuid"
|
||||
@@ -12,8 +13,8 @@ func (h AgendaHandler) CreateEvent(event storage.Event) (*storage.Event, error)
|
||||
event.ID = uuid.NewString()
|
||||
}
|
||||
|
||||
if event.Subscribers == nil {
|
||||
event.Subscribers = []string{}
|
||||
if event.Subscriptions == nil {
|
||||
event.Subscriptions = []storage.Subscription{}
|
||||
}
|
||||
|
||||
if err := h.storage.CreateEvent(event); err != nil {
|
||||
@@ -35,6 +36,13 @@ func (h AgendaHandler) GetEvents(namespaces []string) (events []storage.Event, e
|
||||
}
|
||||
|
||||
func (h AgendaHandler) SubscribeEvent(eventid string, subscriber string) (err error) {
|
||||
err = h.storage.AddSubscriber(eventid, subscriber)
|
||||
subscription := storage.Subscription{
|
||||
Subscriber: subscriber,
|
||||
Tags: []string{},
|
||||
Data: map[string]any{
|
||||
"created_at": time.Now(),
|
||||
},
|
||||
}
|
||||
err = h.storage.AddSubscription(eventid, subscription)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user