Hello from MCP server
package main
import (
"log"
"strings"
// "github.com/pocketbase/pocketbase"
"github.com/pocketbase/pocketbase/core"
)
// registerTagProcessingHooks sets up automatic tag name cleaning
// func registerTagProcessingHooks(app *pocketbase.PocketBase) {
// // Clean tag names when creating new tags
// app.OnRecordCreateRequest().BindFunc(func(e *core.RecordRequestEvent) error {
// if e.Record.Collection().Name == "problemTags" {
// cleanTagName(e)
// }
// return e.Next()
// })
//
// // Clean tag names when updating existing tags
// app.OnRecordUpdateRequest().BindFunc(func(e *core.RecordRequestEvent) error {
// if e.Record.Collection().Name == "problemTags" {
// cleanTagName(e)
// }
// return e.Next()
// })
// }
// cleanTagName processes the tag name and refId fields according to business rules:
// 1. name: Trim whitespace and convert to lowercase (keep spaces intact)
// 2. refId: Trim, lowercase, and replace spaces with hyphens for technical use
func cleanTagName(record *core.Record) {
log.Println("cleaning tag")
name := record.GetString("name")
log.Println(name)
// Clean name: just trim and lowercase, keep spaces
cleanName := strings.ToLower(strings.TrimSpace(name))
log.Println(cleanName)
// Create refId: trim, lowercase, and hyphenate spaces for technical use
refId := strings.ReplaceAll(strings.ToLower(strings.TrimSpace(name)), " ", "-")
record.Set("name", cleanName)
record.Set("refId", refId)
}