Compare commits

...

1 Commits

Author SHA1 Message Date
root
7351756056 make all books public by default (revert visibility gating)
All checks were successful
Release / Test backend (push) Successful in 5m47s
Release / Test UI (push) Successful in 1m4s
Release / Build and push images (push) Successful in 6m20s
Release / Deploy to prod (push) Successful in 3m53s
Release / Deploy to homelab (push) Successful in 8s
Release / Gitea Release (push) Successful in 25s
2026-04-27 11:46:05 +05:00
2 changed files with 43 additions and 2 deletions

View File

@@ -86,12 +86,11 @@ func (s *Store) WriteMetadata(ctx context.Context, meta domain.BookMeta) error {
return fmt.Errorf("WriteMetadata: %w", err)
}
if err == ErrNotFound {
// New scraped book — default to admin_only visibility.
postPayload := make(map[string]any, len(patchPayload)+1)
for k, v := range patchPayload {
postPayload[k] = v
}
postPayload["visibility"] = domain.VisibilityAdminOnly
postPayload["visibility"] = domain.VisibilityPublic
postErr := s.pb.post(ctx, "/api/collections/books/records", postPayload, nil)
if postErr == nil {
return nil

View File

@@ -0,0 +1,42 @@
package migrations
import (
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
)
func init() {
m.Register(func(app core.App) error {
coll, err := app.FindCollectionByNameOrId("books")
if err != nil {
return err
}
if coll.Fields.GetByName("visibility") == nil {
coll.Fields.Add(&core.TextField{Name: "visibility"})
if err := app.Save(coll); err != nil {
return err
}
}
const perPage = 200
for page := 1; ; page++ {
records, err := app.FindRecordsByFilter(
"books", `visibility="admin_only"`, "+id", perPage, (page-1)*perPage, nil,
)
if err != nil || len(records) == 0 {
break
}
for _, rec := range records {
rec.Set("visibility", "public")
_ = app.Save(rec)
}
if len(records) < perPage {
break
}
}
return nil
}, func(app core.App) error {
return nil
})
}