kind 0 implemented, not validating

This commit is contained in:
Chris kerr 2024-07-19 21:12:06 -04:00
parent 1f241c9838
commit 8ba117e2a4

33
events/kind0.go Normal file
View File

@ -0,0 +1,33 @@
package events
import (
"context"
"fmt"
"go.mongodb.org/mongo-driver/mongo"
)
func HandleEventKind0(ctx context.Context, evt Event, collection *mongo.Collection) error {
// Perform specific validation for event kind 1
if !isValidEventKind0(evt) {
return fmt.Errorf("validation failed for event kind 0: %s", evt.ID)
}
// Insert event into MongoDB
_, err := collection.InsertOne(ctx, evt)
if err != nil {
fmt.Println("Error inserting event into MongoDB:", err)
return err
}
fmt.Println("Inserted event kind 1 into MongoDB:", evt.ID)
return nil
}
func isValidEventKind0(evt Event) bool {
// Placeholder for actual validation logic
if evt.Content == "" {
return false
}
return true
}