feat:#36 added new event grpc message

This commit is contained in:
Elmar Kresse
2024-06-18 12:50:21 +02:00
parent 56e77630b5
commit 08140b5802
14 changed files with 510 additions and 50 deletions

View File

@@ -19,9 +19,26 @@ package db
import (
"github.com/pocketbase/pocketbase"
"github.com/pocketbase/pocketbase/models"
"log/slog"
"regexp"
)
func FindCollection(app *pocketbase.PocketBase, collectionName string) (*models.Collection, error) {
collection, dbError := app.Dao().FindCollectionByNameOrId(collectionName)
return collection, dbError
}
// IsSafeIdentifier check uuids against sql injection
// uuids are generated by the system and are not user input
// following the pattern of only containing alphanumeric characters and dashes
func IsSafeIdentifier(uuid string) bool {
// Define a regular expression that matches only valid UUID characters (alphanumeric and dashes)
validUUIDPattern := `^[a-zA-Z0-9-]+$`
match, err := regexp.MatchString(validUUIDPattern, uuid)
if err != nil {
// Handle the error according to your application's needs
slog.Warn("Invalid UUID pattern", "uuid", uuid)
return false
}
return match
}