add Getsubscriber and getsubscriptionbyuser in comments for the moment to avoid crashing

This commit is contained in:
mfrigo 2023-12-08 13:33:13 +01:00
parent 86df552bd1
commit c71851add2
1 changed files with 26 additions and 14 deletions

View File

@ -155,21 +155,33 @@ func (s MongoDBStorage) UpdateEvent(event Event) error {
} }
func (s MongoDBStorage) GetSubscriber(subscriber string) ([]Subscription, error) { func (s MongoDBStorage) GetSubscriber(subscriber string) ([]Subscription, error) {
collection := s.Client.Database(s.DbName).Collection(s.Collections["events"]) // collection := s.Client.Database(s.DbName).Collection(s.Collections["events"])
// subscriptions := []Subscription{}
filter := bson.M{"namespace": subscriber} // cur, err := collection.Find(context.TODO(), bson.M{"subscriptions": bson.M{"$elemMatch": bson.M{"subscriber": subscriber}}})
// if err != nil {
subscription := []Subscription{} // return subscriptions, err
if err := collection.FindOne(context.TODO(), filter).Decode(subscription); err != nil { // }
return nil, err // for cur.Next(context.Background()) {
} // var event Event
return subscription, nil // if err := cur.Decode(&event); err != nil {
// return subscriptions, err
// }
// for i := range event.Subscriptions {
// if event.Subscriptions[i].Subscriber == subscriber {
// subscriptions = append(subscriptions, event.Subscriptions[i])
// }
// }
// }
// return subscriptions, nil
return nil, nil
} }
func (s MongoDBStorage) GetSubscriptionByUser(subscriber string) ([]Subscription, error) { func (s MongoDBStorage) GetSubscriptionByUser(subscriber string) ([]Subscription, error) {
events, err := s.GetSubscriber(subscriber) // events, err := s.GetSubscriber(subscriber)
if err != nil { // if err != nil {
panic(err) // panic(err)
} // }
return events, nil // fmt.Println(events)
// return events, nil
return nil, nil
} }