add id and fix err

This commit is contained in:
soukainna
2024-09-02 21:40:14 +02:00
parent 23c7b50d9b
commit 0e42bd7f79
3 changed files with 74 additions and 13 deletions

View File

@@ -59,6 +59,7 @@ func (h AgendaHandler) SubscribeEvent(eventid string, subscriber string, data ma
subscription := storage.Subscription{
ID: id,
Subscriber: subscriber,
EventID: eventid,
Tags: []string{},
CreatedAt: now,
Data: map[string]any{},
@@ -80,6 +81,7 @@ func (h AgendaHandler) DeleteSubscription(eventid string, subscriber string, dat
deletesubscription := storage.Subscription{
ID: id,
Subscriber: subscriber,
EventID: eventid,
Tags: []string{},
CreatedAt: now,
Data: map[string]any{},
@@ -101,6 +103,17 @@ func (h AgendaHandler) UpdateEvent(event storage.Event) (*storage.Event, error)
return &event, nil
}
func (h AgendaHandler) GetSubscriber(subscriber string) (results []storage.Subscription, err error) {
if subscriber == "" {
return nil, errors.New("missing subscriber")
}
results, err = h.storage.GetSubscriber(subscriber)
if err != nil {
return nil, err
}
return results, nil
}
func (h AgendaHandler) GetSubscriptionByUser(subscriber string) (results []storage.Subscription, err error) {
if subscriber == "" {
return nil, errors.New("missing subscriber")