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) {
collection := s.Client.Database(s.DbName).Collection(s.Collections["events"])
filter := bson.M{"namespace": subscriber}
subscription := []Subscription{}
if err := collection.FindOne(context.TODO(), filter).Decode(subscription); err != nil {
return nil, err
}
return subscription, nil
// collection := s.Client.Database(s.DbName).Collection(s.Collections["events"])
// subscriptions := []Subscription{}
// cur, err := collection.Find(context.TODO(), bson.M{"subscriptions": bson.M{"$elemMatch": bson.M{"subscriber": subscriber}}})
// if err != nil {
// return subscriptions, err
// }
// for cur.Next(context.Background()) {
// var event Event
// 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) {
events, err := s.GetSubscriber(subscriber)
if err != nil {
panic(err)
}
return events, nil
// events, err := s.GetSubscriber(subscriber)
// if err != nil {
// panic(err)
// }
// fmt.Println(events)
// return events, nil
return nil, nil
}