mirror of
https://github.com/0ceanSlim/grain.git
synced 2024-11-22 08:37:13 +00:00
kind 0 implemented, not validating
This commit is contained in:
parent
1f241c9838
commit
8ba117e2a4
33
events/kind0.go
Normal file
33
events/kind0.go
Normal 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
|
||||
}
|
Loading…
Reference in New Issue
Block a user